fix examples
This commit is contained in:
parent
a23452ec20
commit
6998f96078
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
import { Code } from "astro/components"
|
import { Code } from "astro/components"
|
||||||
import { parse } from "node-html-parser"
|
import { parse } from "ultrahtml"
|
||||||
|
import { querySelector } from "ultrahtml/selector"
|
||||||
|
|
||||||
const html = await Astro.slots.render("default")
|
const html = await Astro.slots.render("default")
|
||||||
const parsed = parse(html)
|
const ast = await parse(html)
|
||||||
|
const codetag = querySelector(ast,'code')
|
||||||
const code = parsed.querySelectorAll('code')
|
const { children } = codetag
|
||||||
|
const code = children[0].value
|
||||||
---
|
---
|
||||||
{code.map(item => (
|
<Code code={code} lang={"sh"} theme={"monokai"}/>
|
||||||
<Code lang={"js"} code={item.innerHTML} theme={"dracula"}/>
|
|
||||||
))}
|
|
|
@ -38,8 +38,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"entities": "^4.5.0",
|
"entities": "^4.5.0",
|
||||||
"ultrahtml": "^1.5.2",
|
"ultrahtml": "^1.5.2"
|
||||||
"node-html-parser": "6.1.12"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "4.0.0"
|
"astro": "4.0.0"
|
||||||
|
|
Loading…
Reference in New Issue