mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
24 lines
590 B
Text
24 lines
590 B
Text
---
|
|
//! astro-head-inject
|
|
import type { Config } from '@markdoc/markdoc';
|
|
import Markdoc from '@markdoc/markdoc';
|
|
import { ComponentNode, createTreeNode } from './TreeNode.js';
|
|
|
|
type Props = {
|
|
config: Config;
|
|
stringifiedAst: string;
|
|
};
|
|
|
|
const { stringifiedAst, config } = Astro.props as Props;
|
|
|
|
const ast = Markdoc.Ast.fromJSON(stringifiedAst);
|
|
const content = await Markdoc.transform(ast, config);
|
|
---
|
|
|
|
{
|
|
Array.isArray(content) ? (
|
|
content.map(async (c) => <ComponentNode treeNode={await createTreeNode(c)} />)
|
|
) : (
|
|
<ComponentNode treeNode={await createTreeNode(content)} />
|
|
)
|
|
}
|