diff --git a/libs/storyblok/renderer.js b/libs/storyblok/renderer.js deleted file mode 100644 index f83b1fa..0000000 --- a/libs/storyblok/renderer.js +++ /dev/null @@ -1,64 +0,0 @@ -// https://www.npmjs.com/package/storyblok-rich-text-react-renderer - -import { Image } from 'components/image' -import { Link } from 'components/link' -import { - MARK_LINK, - NODE_HEADING, - NODE_IMAGE, - NODE_PARAGRAPH, - render, -} from 'storyblok-rich-text-react-renderer' - -export function renderRichText( - content, - { markResolvers = {}, nodeResolvers = {}, blokResolvers = {} } = {}, -) { - return render(content, { - markResolvers: { - [MARK_LINK]: (children, { href }) => - children && {children}, - ...markResolvers, - }, - nodeResolvers: { - [NODE_IMAGE]: (children, { src, alt }) => - src && {alt}, - [NODE_HEADING]: (children, { level }) => { - switch (level) { - case 1: - return

{children}

- case 2: - return

{children}

- case 3: - return

{children}

- case 4: - return

{children}

- case 5: - return
{children}
- case 6: - return
{children}
- default: - return null - } - }, - [NODE_PARAGRAPH]: (children) =>

{children}

, - ...nodeResolvers, - }, - blokResolvers: { - ...blokResolvers, - }, - }) -} - -export function RichText({ - content, - markResolvers = {}, - nodeResolvers = {}, - blokResolvers = {}, -}) { - return renderRichText(content, { - markResolvers, - nodeResolvers, - blokResolvers, - }) -}