Add ReplaceNode(similar to WrapNode), and change the name of the called
function to Component, from Wrapped.
Showing
3 changed files
with
15 additions
and
4 deletions
... | @@ -5,8 +5,9 @@ import Node from './node.astro' | ... | @@ -5,8 +5,9 @@ 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 | import WrapNode from './wrap-node.astro' |
8 | import ReplaceNode from './replace-node.astro' | ||
8 | 9 | ||
9 | export { Children, Custom, Match, Node, Replace, External, WrapNode } | 10 | export { Children, Custom, Match, Node, Replace, External, WrapNode, ReplaceNode } |
10 | 11 | ||
11 | import type { NodeType } from 'ultrahtml' | 12 | import type { NodeType } from 'ultrahtml' |
12 | type SlotHandler = (string, NodeType) => Promise<Any> | 13 | type SlotHandler = (string, NodeType) => Promise<Any> | ... | ... |
lib/replace-node.astro
0 → 100644
1 | --- | 1 | --- |
2 | import Node from './node.astro' | 2 | import Node from './node.astro' |
3 | 3 | ||
4 | const { props: { Wrapped, args, special, ...rest } } = Astro | 4 | const { props: { Component, args, special, ...rest } } = Astro |
5 | --- | 5 | --- |
6 | {!special && | 6 | {!special && |
7 | <Wrapped {...args}> | 7 | <Component {...args}> |
8 | <Node {...rest}/> | 8 | <Node {...rest}/> |
9 | </Wrapped> | 9 | </Component> |
10 | } | 10 | } | ... | ... |
-
Please register or sign in to post a comment