UNPKG

react-intlayer

Version:

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

43 lines (40 loc) 1.91 kB
'use client'; const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); const require_editor_useEditedContentRenderer = require('../editor/useEditedContentRenderer.cjs'); const require_markdown_MarkdownProvider = require('./MarkdownProvider.cjs'); let _intlayer_core = require("@intlayer/core"); let _intlayer_editor_react = require("@intlayer/editor-react"); //#region src/markdown/MarkdownRenderer.tsx const MarkdownRenderer = ({ dictionaryKey, keyPath, children, locale }) => { const { renderMarkdown } = require_markdown_MarkdownProvider.useMarkdownContext(); const editedContentContext = require_editor_useEditedContentRenderer.useEditedContentRenderer({ dictionaryKey, keyPath, children }); if (typeof editedContentContext !== "string") { const transformedEditedContent = (0, _intlayer_core.getContent)(editedContentContext, { dictionaryKey, keyPath }, locale); if (typeof transformedEditedContent !== "string") { console.error(`Incorrect Markdown content. Edited Markdown content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`); return renderMarkdown(children); } return renderMarkdown(transformedEditedContent); } return renderMarkdown(editedContentContext); }; const MarkdownMetadataRenderer = ({ dictionaryKey, keyPath, children, metadataKeyPath }) => { const editedContentContext = require_editor_useEditedContentRenderer.useEditedContentRenderer({ dictionaryKey, keyPath, children }); const currentLocale = (0, _intlayer_editor_react.useEditorLocale)(); return (0, _intlayer_core.getContentNodeByKeyPath)((0, _intlayer_core.getMarkdownMetadata)(editedContentContext), metadataKeyPath, currentLocale); }; //#endregion exports.MarkdownMetadataRenderer = MarkdownMetadataRenderer; exports.MarkdownRenderer = MarkdownRenderer; //# sourceMappingURL=MarkdownRenderer.cjs.map