fix: only validate when components is defined

This commit is contained in:
bholmesdev 2023-03-06 12:38:34 -05:00
parent 6e8ba96da9
commit 73af50ba20

View file

@ -7,13 +7,15 @@ import RenderNode from './RenderNode.astro';
type Props = { type Props = {
content: RenderableTreeNode; content: RenderableTreeNode;
components: Record<string, AstroInstance['default']>; components?: Record<string, AstroInstance['default']>;
}; };
const { content, components } = Astro.props as Props; const { content, components } = Astro.props as Props;
// Will throw if components is invalid // Will throw if components is invalid
if (components) {
validateComponentsProp(components); validateComponentsProp(components);
}
--- ---
<RenderNode node={createAstroNode(content, components)} /> <RenderNode node={createAstroNode(content, components)} />