File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22defineProps <{
33 html: string
44}>()
5+
6+ const router = useRouter ()
7+
8+ // We're using only @click because it catches touch events and enter hits
9+ function handleClick(event : MouseEvent ) {
10+ const target = (event ?.target as HTMLElement | undefined )?.closest (' a' )
11+ if (! target ) return
12+
13+ const href = target .getAttribute (' href' )
14+ if (! href ) return
15+
16+ const match = href .match (/ ^ (?:https? :\/\/ )? (?:www\. )? npmjs\. (?:com| org)(\/ . + )$ / )
17+ if (! match || ! match [1 ]) return
18+
19+ const route = router .resolve (match [1 ])
20+ if (route ) {
21+ event .preventDefault ()
22+ router .push (route )
23+ }
24+ }
525 </script >
626
727<template >
8- <article class =" readme prose prose-invert max-w-[70ch] lg:max-w-none" v-html =" html" />
28+ <article
29+ class =" readme prose prose-invert max-w-[70ch] lg:max-w-none"
30+ v-html =" html"
31+ @click =" handleClick"
32+ />
933</template >
1034
1135<style scoped>
Original file line number Diff line number Diff line change @@ -399,24 +399,6 @@ defineOgImageComponent('Package', {
399399 stars : () => stars .value ?? 0 ,
400400 primaryColor: ' #60a5fa' ,
401401})
402-
403- // We're using only @click because it catches touch events and enter hits
404- function handleClick(event : MouseEvent ) {
405- const target = (event ?.target as HTMLElement | undefined )?.closest (' a' )
406- if (! target ) return
407-
408- const href = target .getAttribute (' href' )
409- if (! href ) return
410-
411- const match = href .match (/ ^ (?:https? :\/\/ )? (?:www\. )? npmjs\. (?:com| org)(\/ . + )$ / )
412- if (! match || ! match [1 ]) return
413-
414- const route = router .resolve (match [1 ])
415- if (route ) {
416- event .preventDefault ()
417- router .push (route )
418- }
419- }
420402 </script >
421403
422404<template >
@@ -987,7 +969,7 @@ function handleClick(event: MouseEvent) {
987969 </a >
988970 </h2 >
989971 <!-- eslint-disable vue/no-v-html -- HTML is sanitized server-side -->
990- <Readme v-if =" readmeData?.html" :html =" readmeData.html" @click = " handleClick " />
972+ <Readme v-if =" readmeData?.html" :html =" readmeData.html" />
991973 <p v-else class =" text-fg-subtle italic" >
992974 {{ $t('package.readme.no_readme') }}
993975 <a v-if =" repositoryUrl" :href =" repositoryUrl" rel =" noopener noreferrer" class =" link" >{{
You can’t perform that action at this time.
0 commit comments