Skip to content

Commit 431a634

Browse files
committed
perf(markdown): optimize to call md() fewer times
1 parent 6f3fe15 commit 431a634

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/Markdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ export function Markdown(props: {
252252
runHighlight = false
253253
}
254254
createEffect(
255-
on(md, async () => {
255+
on(md, async (content) => {
256256
setShow(false)
257257
// lazy for math rendering
258-
if (/\$\$[\s\S]+?\$\$|\$[^$\n]+?\$/.test(md())) {
258+
if (/\$\$[\s\S]+?\$\$|\$[^$\n]+?\$/.test(content)) {
259259
const { default: reMarkMath } = await import("remark-math")
260260
const { default: rehypeKatex } = await import("rehype-katex")
261261
insertKatexCSS()

0 commit comments

Comments
 (0)