mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-05-04 10:33:47 +01:00
fix(website): use custom highlighter
This commit is contained in:
parent
fc0e9f96cd
commit
6c20193bd6
1 changed files with 9 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { fetchRegistry, RegistryHttpError } from "$lib/registry-api"
|
import { fetchRegistry, RegistryHttpError } from "$lib/registry-api"
|
||||||
import rehypeShiki from "@shikijs/rehype"
|
import rehypeShikiFromHighlighter from "@shikijs/rehype/core"
|
||||||
import rehypeRaw from "rehype-raw"
|
import rehypeRaw from "rehype-raw"
|
||||||
import rehypeSanitize from "rehype-sanitize"
|
import rehypeSanitize from "rehype-sanitize"
|
||||||
import rehypeStringify from "rehype-stringify"
|
import rehypeStringify from "rehype-stringify"
|
||||||
|
@ -7,10 +7,15 @@ import remarkGemoji from "remark-gemoji"
|
||||||
import remarkGfm from "remark-gfm"
|
import remarkGfm from "remark-gfm"
|
||||||
import remarkParse from "remark-parse"
|
import remarkParse from "remark-parse"
|
||||||
import remarkRehype from "remark-rehype"
|
import remarkRehype from "remark-rehype"
|
||||||
import { createCssVariablesTheme } from "shiki"
|
import { createCssVariablesTheme, createHighlighter } from "shiki"
|
||||||
import { unified } from "unified"
|
import { unified } from "unified"
|
||||||
import type { PageLoad } from "./$types"
|
import type { PageLoad } from "./$types"
|
||||||
|
|
||||||
|
const highlighter = await createHighlighter({
|
||||||
|
themes: [],
|
||||||
|
langs: [],
|
||||||
|
})
|
||||||
|
|
||||||
const fetchReadme = async (
|
const fetchReadme = async (
|
||||||
fetcher: typeof fetch,
|
fetcher: typeof fetch,
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -50,14 +55,14 @@ export const load: PageLoad = async ({ parent, fetch }) => {
|
||||||
.use(remarkRehype, { allowDangerousHtml: true })
|
.use(remarkRehype, { allowDangerousHtml: true })
|
||||||
.use(rehypeRaw)
|
.use(rehypeRaw)
|
||||||
.use(rehypeSanitize)
|
.use(rehypeSanitize)
|
||||||
.use(rehypeShiki, {
|
.use(rehypeShikiFromHighlighter, highlighter, {
|
||||||
|
lazy: true,
|
||||||
theme: createCssVariablesTheme({
|
theme: createCssVariablesTheme({
|
||||||
name: "css-variables",
|
name: "css-variables",
|
||||||
variablePrefix: "--shiki-",
|
variablePrefix: "--shiki-",
|
||||||
variableDefaults: {},
|
variableDefaults: {},
|
||||||
fontStyle: true,
|
fontStyle: true,
|
||||||
}),
|
}),
|
||||||
lazy: true,
|
|
||||||
fallbackLanguage: "text",
|
fallbackLanguage: "text",
|
||||||
})
|
})
|
||||||
.use(rehypeStringify)
|
.use(rehypeStringify)
|
||||||
|
|
Loading…
Add table
Reference in a new issue