npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

frank-react-sdk

v1.0.7

Published

This is a SDK to consume frank-data from your React/NextJS app.

Downloads

33

Readme

frank-react-sdk

This is a SDK to consume frank-data from your React/NextJS app.

Configuration

The connection details can be configured in two ways, by environment variables or when initialising the client.

Environment variables

Set the following environment variables to configure your connection details. | Variable | Description | |--|--| |FRANK_BASEURL | URL to your Frank installation | |FRANK_SPACEID | ID of space to load information from | |FRANK_ACCESSKEY | Content Access Key to use when using the client |

When initialising the client

const client = new FrankClient({
    baseUrl : "https://demo.frank",
    spaceId : "s00000000",
    accessKey :  "..."
});

Querying items

const items = await client.GetItems(options)

Options

When querying data all parameters that can be used in the Frank Content APIcan be used. | Option | Description | |--|--| |contentId | Comma separated list of contentIds | |contentTypeId | Comma separated list of content types | |folderId | Comma separated list of folderIds | |languageId | Comma separated list of languages to include | |expand | Set to 'true' if referenced content should be expanded | |expandLevels | Content Access Key to use when using the client | |expandFallbackLanguageId | How many levels to expand when expanding referenced content. Default to 1. | |query | Query Content with a MongoDB style query. | |project | Comma separated list of fields to return from the data property. | |slug | Comma separated list of slugs to query | |sort | Comma separated list of fields to sort by, or sort object | |sortDirection | asc or desc |

Querying item

const item = await client.GetItem(options)

Options

Same option as above

Render content

Content from Frank can be rendered in your app just as any data. However, frank-react-sdk comes with a few helper components that can render data for you.

Markdown

With the <Markdown/> component you can easily render markdown markup. Simply pass your markdown code as children to the component.

import { Markdown } from  "frank-react-sdk"

function render(){
   return <Markdown>hello *world*</MarkDown>
} 

You can also specity what node type that the markdown should be rendered as by specifying the as attribute:

 <Markdown as="h1">hello *world*</MarkDown>

Blocks data type

If you have data stored in the Blocks data type from Frank you can use the <Blocks/> object to convert the Blocks data into HTML and/or JSX.

To render the content of a Blocks field simply use:

import { Blocks } from  "frank-react-sdk"

function render(){
   return <Blocks value={item.data.field}/>
} 

The Blocks component have various options that can be passed as props to the component | Property | Description | |--|--| | value | Array of blocks to render | | renderMarkdown | Set to true if text content should be handled as markdown | | blockContainer | What element type should be used as the container for all blocks, defaults to div | | blockRenderer | A function that will be used to render each block, should return ReactNode| | paragraphRenderer | A function that will be used to paragraph blocks, should return ReactNode| | headingRenderer | A function that will be used to heading blocks, should return ReactNode| | codeRenderer | A function that will be used to code blocks, should return ReactNode| | referenceRenderer | A function that will be used to referece blocks, should return ReactNode| | tableRenderer | A function that will be used to table blocks, should return ReactNode| | dividerRenderer | A function that will be used to divder blocks, should return ReactNode| | assetRenderer | A function that will be used to asset blocks, should return ReactNode|