Skip to content

Commit a268db2

Browse files
committed
fix: add plain prop to avoid rendering link within PackageCard.
1 parent 9929e0c commit a268db2

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

app/components/MarkdownText.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
const props = defineProps<{
33
text: string
4+
/** When true, renders link text without the anchor tag (useful when inside another link) */
5+
plain?: boolean
46
}>()
57
68
// Escape HTML to prevent XSS
@@ -36,6 +38,10 @@ function parseMarkdown(text: string): string {
3638
3739
// Links: [text](url) - only allow https, mailto
3840
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, text, url) => {
41+
// In plain mode, just render the link text without the anchor
42+
if (props.plain) {
43+
return text
44+
}
3945
const decodedUrl = url.replace(/&amp;/g, '&')
4046
try {
4147
const parsed = new URL(decodedUrl)

app/components/PackageCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const emit = defineEmits<{
6262
v-if="result.package.description"
6363
class="text-fg-muted text-xs sm:text-sm line-clamp-2 mb-2 sm:mb-3"
6464
>
65-
<MarkdownText :text="result.package.description" />
65+
<MarkdownText :text="result.package.description" plain />
6666
</p>
6767
<div class="flex flex-wrap items-center gap-x-3 sm:gap-x-4 gap-y-2 text-xs text-fg-subtle">
6868
<dl v-if="showPublisher || result.package.date" class="flex items-center gap-4 m-0">

0 commit comments

Comments
 (0)