summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/components/Renderer.astro
blob: 4fce72b0407fb59828fcf3a14b9474667b64b6b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---
import type { RenderableTreeNode } from '@markdoc/markdoc';
import type { AstroInstance } from 'astro';
import { validateComponentsProp } from '../dist/utils.js';
import { createAstroNode } from './astroNode';
import RenderNode from './RenderNode.astro';

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);
}
---

<RenderNode node={createAstroNode(content, components)} />