astro/examples/with-markdoc/src/renderer/RenderNode.astro

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
556 B
Text
Raw Normal View History

---
import type { AstroNode } from './astroNode';
type Props = {
node: AstroNode;
};
const Node = (Astro.props as Props).node;
---
{
typeof Node === 'string' ? (
<Fragment set:text={Node} />
) : 'component' in Node ? (
<Node.component {...Node.props}>
{Node.children.map((child) => (
<Astro.self node={child} />
))}
</Node.component>
) : (
<Fragment>
<Fragment set:html={`<${Node.tag}>`} />
{Node.children.map((child) => (
<Astro.self node={child} />
))}
<Fragment set:html={`</${Node.tag}>`} />
</Fragment>
)
}