[READ-ONLY] a fast, modern browser for the npm registry
at main 35 lines 1.1 kB view raw
1<script setup lang="ts"> 2import { parseLicenseExpression } from '#shared/utils/spdx' 3 4const props = defineProps<{ 5 license: string 6}>() 7 8const tokens = computed(() => parseLicenseExpression(props.license)) 9 10const hasAnyValidLicense = computed(() => tokens.value.some(t => t.type === 'license' && t.url)) 11</script> 12 13<template> 14 <span class="inline-flex items-baseline gap-x-1.5 flex-wrap gap-y-0.5"> 15 <template v-for="(token, i) in tokens" :key="i"> 16 <a 17 v-if="token.type === 'license' && token.url" 18 :href="token.url" 19 target="_blank" 20 rel="noopener noreferrer" 21 class="link-subtle" 22 :title="$t('package.license.view_spdx')" 23 > 24 {{ token.value }} 25 </a> 26 <span v-else-if="token.type === 'license'">{{ token.value }}</span> 27 <span v-else-if="token.type === 'operator'" class="text-4xs">{{ token.value }}</span> 28 </template> 29 <span 30 v-if="hasAnyValidLicense" 31 class="i-lucide:scale w-3.5 h-3.5 text-fg-subtle flex-shrink-0 self-center" 32 aria-hidden="true" 33 /> 34 </span> 35</template>