Skip to content

Commit

Permalink
fix: missing font of katex (close AlistGo/alist#5417)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Oct 22, 2023
1 parent ab6701c commit d7febf8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1,129 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"copy-to-clipboard": "^3.3.2",
"flv.js": "^1.6.2",
"hls.js": "^1.2.1",
"just-once": "^2.2.0",
"lightgallery": "^2.5.0",
"mark.js": "^8.11.1",
"mitt": "^3.0.0",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import rehypeRaw from "rehype-raw"
import reMarkMath from "remark-math"
import rehypeKatex from "rehype-katex"
import "./markdown.css"
import "./katex.css"
import { Show, createEffect, createMemo, createSignal, on } from "solid-js"
import { clsx } from "clsx"
import { Box } from "@hope-ui/solid"
import { useParseText } from "~/hooks"
import { EncodingSelect } from "."
import once from "just-once"

const insertKatexCSS = once(() => {
const link = document.createElement("link")
link.rel = "stylesheet"
link.href =
"https://registry.npmmirror.com/katex/0.16.8/files/dist/katex.min.css"
document.head.appendChild(link)
})

export const Markdown = (props: {
children?: string | ArrayBuffer
Expand All @@ -31,6 +39,7 @@ export const Markdown = (props: {
createEffect(
on(md, () => {
setShow(false)
insertKatexCSS()
setTimeout(() => {
setShow(true)
hljs.highlightAll()
Expand Down
Loading

0 comments on commit d7febf8

Please sign in to comment.