Skip to content

Commit 0c285fa

Browse files
committed
fix: use escapeHtml from vitepress
1 parent f3b98f7 commit 0c285fa

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@types/node": "^20.12.12",
5454
"prettier": "^3.2.5",
5555
"typescript": "^5.4.5",
56-
"vitepress": "^1.2.0",
56+
"vitepress": "^1.2.2",
5757
"vue": "^3.4.27",
5858
"vue-tsc": "^2.0.19"
5959
},

pnpm-lock.yaml

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vitepress/components/VPDocOutlineItem.vue

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { useData } from 'vitepress'
2+
import { useData, _escapeHtml } from 'vitepress'
33
import type { MenuItemWithLinkAndChildren } from '../composables/outline.js'
44
55
defineProps<{
@@ -16,11 +16,6 @@ function onClick({ target: el }: Event) {
1616
)
1717
heading?.focus()
1818
}
19-
20-
function escape(str: string): string {
21-
// & will be already escaped
22-
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
23-
}
2419
</script>
2520

2621
<template>
@@ -31,7 +26,7 @@ function escape(str: string): string {
3126
:href="link"
3227
@click="onClick"
3328
v-show="!hidden"
34-
v-html="escape(text)"
29+
v-html="_escapeHtml(text)"
3530
/>
3631
<template v-if="children?.length && frontmatter.outline === 'deep'">
3732
<VPDocOutlineItem :headers="children" :nested="true" />

0 commit comments

Comments
 (0)