@@ -5,41 +5,36 @@ const isValid = ref(true)
55const copied = ref (false )
66
77const types = [
8- ' version' ,
9- ' license' ,
10- ' size' ,
11- ' downloads' ,
12- ' downloads-day' ,
13- ' downloads-week' ,
14- ' downloads-month' ,
15- ' downloads-year' ,
16- ' vulnerabilities' ,
17- ' dependencies' ,
18- ' created' ,
19- ' updated' ,
20- ' engines' ,
21- ' types' ,
22- ' maintainers' ,
23- ' deprecated' ,
24- ' quality' ,
25- ' popularity' ,
26- ' maintenance' ,
27- ' score' ,
28- ' name' ,
8+ ' version' , ' license' , ' size' , ' downloads' , ' downloads-day' ,
9+ ' downloads-week' , ' downloads-month' , ' downloads-year' ,
10+ ' vulnerabilities' , ' dependencies' , ' created' , ' updated' ,
11+ ' engines' , ' types' , ' maintainers' , ' deprecated' ,
12+ ' quality' , ' popularity' , ' maintenance' , ' score' , ' name' ,
2913]
3014
3115watch (pkg, () => {
3216 isValid .value = true
3317})
3418
19+ const formatLabel = (str ) => {
20+ if (! str || typeof str !== ' string' ) return ' '
21+ return str
22+ .split (' -' )
23+ .map (word => word .charAt (0 ).toUpperCase () + word .slice (1 ))
24+ .join (' per ' )
25+ }
26+
3527const copyToClipboard = async () => {
3628 const markdown = ` [](https://npmx.dev/package/${ pkg .value } )`
37- await navigator .clipboard .writeText (markdown)
38-
39- copied .value = true
40- setTimeout (() => {
41- copied .value = false
42- }, 2000 )
29+ try {
30+ await navigator .clipboard .writeText (markdown)
31+ copied .value = true
32+ setTimeout (() => {
33+ copied .value = false
34+ }, 2000 )
35+ } catch {
36+ console .error (' Failed to copy to clipboard' )
37+ }
4338}
4439 </script >
4540
@@ -70,7 +65,7 @@ const copyToClipboard = async () => {
7065 v-model =" type"
7166 class =" w-full h-10.5 px-4 py-2 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-black/20 focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500 outline-none text-sm transition-all appearance-none cursor-pointer"
7267 >
73- <option v-for =" t in types" :key =" t" :value =" t" class =" dark:bg-gray-900" >{{ t }}</option >
68+ <option v-for =" t in types" :key =" t" :value =" t" class =" dark:bg-gray-900" >{{ formatLabel(t) }}</option >
7469 </select >
7570 <span
7671 class =" absolute right-3 top-1/2 -translate-y-1/2 i-lucide-chevron-down w-4 h-4 text-gray-400 pointer-events-none"
0 commit comments