Add directly callable helper component that can be used to wrap nodes.
Showing
3 changed files
with
11 additions
and
2 deletions
| ... | @@ -4,8 +4,9 @@ import Match from './match.astro' | ... | @@ -4,8 +4,9 @@ import Match from './match.astro' |
| 4 | import Node from './node.astro' | 4 | import Node from './node.astro' |
| 5 | import Replace from './replace.astro' | 5 | import Replace from './replace.astro' |
| 6 | import External from './external.astro' | 6 | import External from './external.astro' |
| 7 | import WrapNode from './wrap-node.astro' | ||
| 7 | 8 | ||
| 8 | export { Children, Custom, Match, Node, Replace, External } | 9 | export { Children, Custom, Match, Node, Replace, External, WrapNode } |
| 9 | 10 | ||
| 10 | import type { NodeType } from 'ultrahtml' | 11 | import type { NodeType } from 'ultrahtml' |
| 11 | type SlotHandler = (string, NodeType) => Promise<Any> | 12 | type SlotHandler = (string, NodeType) => Promise<Any> | ... | ... |
| ... | @@ -22,7 +22,7 @@ const [ Component, componentArgs, componentContent ] = Array.isArray(slotName) ? | ... | @@ -22,7 +22,7 @@ const [ Component, componentArgs, componentContent ] = Array.isArray(slotName) ? |
| 22 | --- | 22 | --- |
| 23 | { | 23 | { |
| 24 | typeof Component === 'string' ? <Component {...node.attributes} {...componentArgs}>{componentContent}</Component> | 24 | typeof Component === 'string' ? <Component {...node.attributes} {...componentArgs}>{componentContent}</Component> |
| 25 | : Component ? (<Component {...componentArgs} debug={nextDebug} replacers={replacers} slotHandler={slotHandler}/>) | 25 | : Component ? (<Component {...componentArgs} parent={parent} node={node} index={index} debug={nextDebug} replacers={replacers} slotHandler={slotHandler} special={special}>{componentContent}</Component>) |
| 26 | : slotName ? slotHandler(slotName, node, special) | 26 | : slotName ? slotHandler(slotName, node, special) |
| 27 | : <Node parent={parent} node={node} index={index} debug={nextDebug} replacers={replacers} slotHandler={slotHandler} special={special}/> | 27 | : <Node parent={parent} node={node} index={index} debug={nextDebug} replacers={replacers} slotHandler={slotHandler} special={special}/> |
| 28 | } | 28 | } | ... | ... |
-
Please register or sign in to post a comment