UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

36 lines 953 B
import { getContent } from "../../interpreter/getContent/getContent.mjs"; import { formatNodeType, NodeType } from "../../types/index.mjs"; import { getMarkdownMetadata } from "./getMarkdownMetadata.mjs"; const awaitContent = async (content) => { if (typeof content === "string" || typeof content === "object") { return content; } if (typeof content === "function") { return content(); } if (typeof content.then === "function") { return await content; } }; const markdown = (content) => { const metadata = async () => { const awaitedContent = await awaitContent(content); const flatContent = getContent(awaitedContent, { dictionaryKey: "", keyPath: [] }); if (typeof flatContent === "string") { return getMarkdownMetadata(flatContent); } }; return formatNodeType(NodeType.Markdown, content, { metadata }); }; export { markdown as md }; //# sourceMappingURL=markdown.mjs.map