2023-02-06 21:11:15 +00:00
|
|
|
---
|
|
|
|
import type { RenderableTreeNode } from '@markdoc/markdoc';
|
2023-03-01 19:20:48 +00:00
|
|
|
import type { AstroInstance } from 'astro';
|
2023-03-06 15:05:59 +00:00
|
|
|
import { validateComponentsProp } from '../dist/utils.js';
|
2023-03-01 19:20:48 +00:00
|
|
|
import { createAstroNode } from './astroNode';
|
2023-02-06 21:11:15 +00:00
|
|
|
import RenderNode from './RenderNode.astro';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
content: RenderableTreeNode;
|
2023-03-06 17:38:34 +00:00
|
|
|
components?: Record<string, AstroInstance['default']>;
|
2023-02-06 21:11:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const { content, components } = Astro.props as Props;
|
2023-03-06 15:05:59 +00:00
|
|
|
|
|
|
|
// Will throw if components is invalid
|
2023-03-06 17:38:34 +00:00
|
|
|
if (components) {
|
|
|
|
validateComponentsProp(components);
|
|
|
|
}
|
2023-02-06 21:11:15 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
<RenderNode node={createAstroNode(content, components)} />
|