@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
37 lines (35 loc) • 1.33 kB
JavaScript
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
const require_interpreter_getContent_getContent = require('../../interpreter/getContent/getContent.cjs');
const require_transpiler_markdown_getMarkdownMetadata = require('./getMarkdownMetadata.cjs');
let __intlayer_types = require("@intlayer/types");
//#region src/transpiler/markdown/markdown.ts
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;
};
/**
* Function intended to be used to build intlayer dictionaries.
*
* Allow to pick a content based on a quantity.
*
* Usage:
*
* ```ts
* markdown('## Hello world!');
* ```
*
*/
const markdown = (content) => {
const metadata = async () => {
const flatContent = require_interpreter_getContent_getContent.getContent(await awaitContent(content), {
dictionaryKey: "",
keyPath: []
});
if (typeof flatContent === "string") return require_transpiler_markdown_getMarkdownMetadata.getMarkdownMetadata(flatContent);
};
return (0, __intlayer_types.formatNodeType)(__intlayer_types.NodeType.Markdown, content, { metadata });
};
//#endregion
exports.md = markdown;
//# sourceMappingURL=markdown.cjs.map