abfc737a by Adam Heath

Allow for multiple xpath matches at the top level.

1 parent 82b35ef4
......@@ -18,10 +18,10 @@ export const getDocFromProps = async (props, options) => {
return parseHtml(html, { ...options, adjuster })
}
export const getNodeFromProps = async (props, options) => {
export const getNodesFromProps = async (props, options) => {
const doc = await getDocFromProps(props, options)
const { xpath } = props
return xpath ? findNode(doc, xpath) : doc
return xpath ? findNode(doc, xpath, { single: false }) : [ doc ]
}
export const createAdjuster = (adjustments = {}) => {
......@@ -39,8 +39,8 @@ export const createAdjuster = (adjustments = {}) => {
const { props } = Astro
const { debug, replacers, slotHandler } = props
const node = await getNodeFromProps(props)
const nodes = await getNodesFromProps(props)
const nextDebug = debug ? debug - 1 : 0
---
<Match node={node} debug={nextDebug} replacers={replacers} slotHandler={slotHandler} adjuster={adjuster}/>
{nodes.map(node => <Match node={node} debug={nextDebug} replacers={replacers} slotHandler={slotHandler}/>)}
......