astro/packages/integrations/markdoc/components/Renderer.astro
Ben Holmes 86273b5881
[Markdoc] Refactor Renderer internals to use renderComponent() (#6607)
* wip: new TreeNode setup

* fix: pass children through `render`

* deps: remove stringify-attributes

* chore: changeset

---------

Co-authored-by: Nate Moore <nate@astro.build>
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
2023-03-21 08:17:20 -04:00

20 lines
557 B
Text

---
import type { RenderableTreeNode } from '@markdoc/markdoc';
import type { AstroInstance } from 'astro';
import { validateComponentsProp } from '../dist/utils.js';
import { ComponentNode, createTreeNode } from './TreeNode.js';
type Props = {
content: RenderableTreeNode;
components?: Record<string, AstroInstance['default']>;
};
const { content, components } = Astro.props as Props;
// Will throw if components is invalid
if (components) {
validateComponentsProp(components);
}
---
<ComponentNode treeNode={createTreeNode(content, components)} />