2023-02-06 21:11:15 +00:00
|
|
|
---
|
2023-02-06 22:04:22 +00:00
|
|
|
import stringifyAttributes from 'stringify-attributes';
|
2023-02-06 21:11:15 +00:00
|
|
|
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>
|
2023-02-06 22:04:22 +00:00
|
|
|
<Fragment set:html={`<${Node.tag} ${stringifyAttributes(Node.attributes)}>`} />
|
2023-02-06 21:11:15 +00:00
|
|
|
{Node.children.map((child) => (
|
|
|
|
<Astro.self node={child} />
|
|
|
|
))}
|
|
|
|
<Fragment set:html={`</${Node.tag}>`} />
|
|
|
|
</Fragment>
|
|
|
|
)
|
|
|
|
}
|