UNPKG

react-intlayer

Version:

Easily internationalize i18n your React applications with type-safe multilingual content management.

1 lines 1.42 kB
{"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { FC, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\nimport { compileMarkdown } from './processor';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FC<MarkdownRendererPluginProps> = (\n props\n): ReactNode => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n\n if (context) {\n return context.renderMarkdown(children, options, {\n ...context.components,\n ...components,\n }) as ReactNode;\n }\n\n return compileMarkdown(children, { ...options, components });\n};\n"],"mappings":";;;;;;AAqBA,MAAa,0BACX,UACc;CACd,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAU,oBAAoB;AAEpC,KAAI,QACF,QAAO,QAAQ,eAAe,UAAU,SAAS;EAC/C,GAAG,QAAQ;EACX,GAAG;EACJ,CAAC;AAGJ,QAAO,gBAAgB,UAAU;EAAE,GAAG;EAAS;EAAY,CAAC"}