Skip to content

Commit 6c03171

Browse files
committed
fix: do not use v-html on a custom component
1 parent 57975af commit 6c03171

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

app/components/Readme.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<!-- simple component only taking slot -->
1+
<script setup lang="ts">
2+
defineProps<{
3+
html: string
4+
}>()
5+
</script>
6+
27
<template>
3-
<article class="readme prose prose-invert max-w-[70ch]">
4-
<slot />
5-
</article>
8+
<article class="readme prose prose-invert max-w-[70ch]" v-html="html" />
69
</template>
710

811
<style scoped>

app/pages/[...package].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ function handleClick(event: MouseEvent) {
954954
</a>
955955
</h2>
956956
<!-- eslint-disable vue/no-v-html -- HTML is sanitized server-side -->
957-
<Readme v-if="readmeData?.html" v-html="readmeData.html" @click="handleClick" />
957+
<Readme v-if="readmeData?.html" :html="readmeData.html" @click="handleClick" />
958958
<p v-else class="text-fg-subtle italic">
959959
{{ $t('package.readme.no_readme') }}
960960
<a v-if="repositoryUrl" :href="repositoryUrl" rel="noopener noreferrer" class="link">{{

app/pages/code/[...path].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ defineOgImageComponent('Default', {
442442
v-show="markdownViewMode === 'preview'"
443443
class="flex justify-center p-4"
444444
>
445-
<Readme v-html="fileContent.markdownHtml.html" />
445+
<Readme :html="fileContent.markdownHtml.html" />
446446
</div>
447447

448448
<CodeViewer

0 commit comments

Comments
 (0)