Renderer.astro 584 B

123456789101112131415161718192021222324
  1. ---
  2. //! astro-head-inject
  3. import type { Config } from '@markdoc/markdoc';
  4. import Markdoc from '@markdoc/markdoc';
  5. import { ComponentNode, createTreeNode } from './TreeNode.js';
  6. type Props = {
  7. config: Config;
  8. stringifiedAst: string;
  9. };
  10. const { stringifiedAst, config } = Astro.props as Props;
  11. const ast = Markdoc.Ast.fromJSON(stringifiedAst);
  12. const content = Markdoc.transform(ast, config);
  13. ---
  14. {
  15. Array.isArray(content) ? (
  16. content.map(async (c) => <ComponentNode treeNode={await createTreeNode(c)} />)
  17. ) : (
  18. <ComponentNode treeNode={await createTreeNode(content)} />
  19. )
  20. }