Skip to content

Commit

Permalink
chore: use tiny-decode instead of v-html+escapeHtml
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed May 22, 2024
1 parent 82f5d69 commit fbef70c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"@docsearch/js": "^3.6.0",
"@vueuse/core": "^10.9.0",
"body-scroll-lock": "^4.0.0-beta.0",
"normalize.css": "^8.0.1"
"normalize.css": "^8.0.1",
"tiny-decode": "^0.1.3"
},
"devDependencies": {
"@mdit-vue/types": "^2.1.0",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

13 changes: 5 additions & 8 deletions src/vitepress/components/VPDocOutlineItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { useData, _escapeHtml } from 'vitepress'
import { decode } from 'tiny-decode'
import { useData } from 'vitepress'
import type { MenuItemWithLinkAndChildren } from '../composables/outline.js'
defineProps<{
Expand All @@ -21,13 +22,9 @@ function onClick({ target: el }: Event) {
<template>
<ul :class="nested ? 'nested' : 'root'">
<li v-for="{ children, link, text, hidden } in headers">
<a
class="outline-link"
:href="link"
@click="onClick"
v-show="!hidden"
v-html="_escapeHtml(text)"
/>
<a class="outline-link" :href="link" @click="onClick" v-show="!hidden">
{{ decode(text) }}
</a>
<template v-if="children?.length && frontmatter.outline === 'deep'">
<VPDocOutlineItem :headers="children" :nested="true" />
</template>
Expand Down

0 comments on commit fbef70c

Please sign in to comment.