@@ -72,11 +72,21 @@ const {
7272 isLoadingMore,
7373 hasMore,
7474 fetchMore,
75+ error,
7576} = useNpmSearch (query , () => ({
7677 size: requestedSize .value ,
7778 incremental: true ,
7879}))
7980
81+ interface SearchError {
82+ code? : string
83+ }
84+
85+ const hasTextLengthError = computed <boolean >(() => {
86+ const errorData = error .value ?.data as SearchError | undefined
87+ return errorData ?.code === ' ERR_TEXT_LENGTH'
88+ })
89+
8090// Results to display (directly from incremental search)
8191const rawVisibleResults = computed (() => results .value )
8292
@@ -594,6 +604,25 @@ defineOgImageComponent('Default', {
594604 <h1 class =" font-mono text-2xl sm:text-3xl font-medium mb-4" >
595605 {{ $t('search.title') }}
596606 </h1 >
607+ <div
608+ v-if =" hasTextLengthError"
609+ class =" mb-6 p-4 bg-bg-subtle border border-border rounded-lg flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4"
610+ >
611+ <div class =" flex-1 min-w-0" >
612+ <p class =" font-mono text-sm text-fg" >
613+ {{ $t('search.not_invalid') }}
614+ </p >
615+ <p class =" text-xs text-fg-muted mt-0.5" >
616+ {{ $t('search.not_invalid_description') }}
617+ </p >
618+ </div >
619+ <NuxtLink
620+ :to =" { name: 'package', params: { package: [query] } }"
621+ class =" shrink-0 px-4 py-2 font-mono text-sm text-bg bg-fg rounded-md hover:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
622+ >
623+ {{ $t('search.not_invalid_button_label', { name: query }) }}
624+ </NuxtLink >
625+ </div >
597626
598627 <section v-if =" query" >
599628 <!-- Initial loading (only after user interaction, not during view transition) -->
@@ -698,7 +727,7 @@ defineOgImageComponent('Default', {
698727 </div >
699728
700729 <!-- No results found -->
701- <div v-else-if =" status !== 'pending'" role =" status" class =" py-12" >
730+ <div v-else-if =" status !== 'pending' && !hasTextLengthError " role =" status" class =" py-12" >
702731 <p class =" text-fg-muted font-mono mb-6 text-center" >
703732 {{ $t('search.no_results', { query }) }}
704733 </p >
0 commit comments