mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
31 lines
652 B
Text
31 lines
652 B
Text
|
---
|
||
|
import stringifyAttributes from 'stringify-attributes';
|
||
|
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} ${stringifyAttributes(Node.attributes)}>`} />
|
||
|
{Node.children.map((child) => (
|
||
|
<Astro.self node={child} />
|
||
|
))}
|
||
|
<Fragment set:html={`</${Node.tag}>`} />
|
||
|
</Fragment>
|
||
|
)
|
||
|
}
|