Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
astro-wt
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
17c366bb
authored
2025-02-03 16:16:53 -0600
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add directly callable helper component that can be used to wrap nodes.
1 parent
f7398eea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
lib/astro.ts
lib/match.astro
lib/wrap-node.astro
lib/astro.ts
View file @
17c366b
...
...
@@ -4,8 +4,9 @@ import Match from './match.astro'
import
Node
from
'./node.astro'
import
Replace
from
'./replace.astro'
import
External
from
'./external.astro'
import
WrapNode
from
'./wrap-node.astro'
export
{
Children
,
Custom
,
Match
,
Node
,
Replace
,
External
}
export
{
Children
,
Custom
,
Match
,
Node
,
Replace
,
External
,
WrapNode
}
import
type
{
NodeType
}
from
'ultrahtml'
type
SlotHandler
=
(
string
,
NodeType
)
=>
Promise
<
Any
>
...
...
lib/match.astro
View file @
17c366b
...
...
@@ -22,7 +22,7 @@ const [ Component, componentArgs, componentContent ] = Array.isArray(slotName) ?
---
{
typeof Component === 'string' ? <Component {...node.attributes} {...componentArgs}>{componentContent}</Component>
: Component ? (<Component {...componentArgs}
debug={nextDebug} replacers={replacers} slotHandler={slotHandler}/
>)
: Component ? (<Component {...componentArgs}
parent={parent} node={node} index={index} debug={nextDebug} replacers={replacers} slotHandler={slotHandler} special={special}>{componentContent}</Component
>)
: slotName ? slotHandler(slotName, node, special)
: <Node parent={parent} node={node} index={index} debug={nextDebug} replacers={replacers} slotHandler={slotHandler} special={special}/>
}
...
...
lib/wrap-node.astro
0 → 100644
View file @
17c366b
---
import Node from './node.astro'
const { props: { Wrapped, args, ...rest } } = Astro
---
<Wrapped {...args}>
<Node {...rest}/>
</Wrapped>
Please
register
or
sign in
to post a comment