File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ const { query } = defineProps <{
3+ query: string
4+ }>()
5+
6+ const { data : result, status } = useExactPackage (query )
7+ </script >
8+
9+ <template >
10+ <PackageCard v-if =" result" :result heading-level =" h2" :search-query =" query" />
11+ <p v-else-if =" status !== 'pending'" class =" text-fg-muted font-mono mb-6 text-center" >
12+ {{ $t('search.no_results', { query }) }}
13+ </p >
14+ </template >
Original file line number Diff line number Diff line change @@ -586,6 +586,29 @@ export function useOrgPackages(orgName: MaybeRefOrGetter<string>) {
586586 return asyncData
587587}
588588
589+ /**
590+ * Returns a single package as an NpmSearchResult
591+ * Similar to useNpmSearch but for exact package lookups
592+ */
593+ export function useExactPackage ( query : MaybeRefOrGetter < string > ) {
594+ const { data : pkg , status, error } = usePackage ( query )
595+ const { data : downloads } = usePackageDownloads ( query )
596+
597+ const data = computed < NpmSearchResult | undefined > ( ( ) => {
598+ if ( ! pkg . value ) {
599+ return undefined
600+ }
601+
602+ return packumentToSearchResult ( pkg . value , downloads . value ?. downloads )
603+ } )
604+
605+ return {
606+ data,
607+ status,
608+ error,
609+ }
610+ }
611+
589612// ============================================================================
590613// Package Versions
591614// ============================================================================
Original file line number Diff line number Diff line change @@ -709,25 +709,7 @@ defineOgImageComponent('Default', {
709709
710710 <!-- No results found -->
711711 <div v-else-if =" status !== 'pending'" role =" status" class =" py-12" >
712- <div
713- v-if =" hasTextLengthError"
714- class =" p-4 bg-bg-subtle border border-border rounded-lg flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4"
715- >
716- <div class =" flex-1 min-w-0" >
717- <p class =" font-mono text-sm text-fg" >
718- {{ $t('search.not_invalid') }}
719- </p >
720- <p class =" text-xs text-fg-muted mt-0.5" >
721- {{ $t('search.not_invalid_description') }}
722- </p >
723- </div >
724- <NuxtLink
725- :to =" { name: 'package', params: { package: [query] } }"
726- class =" shrink-0 px-4 py-2 font-mono text-sm text-bg bg-fg rounded-md hover:bg-fg/90 hover:text-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
727- >
728- {{ $t('search.not_invalid_button_label', { name: query }) }}
729- </NuxtLink >
730- </div >
712+ <PackageCardExact v-if =" hasTextLengthError" :query />
731713 <p v-else class =" text-fg-muted font-mono mb-6 text-center" >
732714 {{ $t('search.no_results', { query }) }}
733715 </p >
You can’t perform that action at this time.
0 commit comments