File tree Expand file tree Collapse file tree 5 files changed +30
-7
lines changed
Expand file tree Collapse file tree 5 files changed +30
-7
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import { motion } from ' motion-v'
33import type { VariantType } from ' motion-v'
4+ import { useLocale } from ' @nuxt/ui/composables/useLocale'
45
56const props = defineProps <{
67 open: boolean
Original file line number Diff line number Diff line change @@ -79,7 +79,10 @@ watch(page, (page) => {
7979}, { immediate: true })
8080
8181// Get the -2 item of the breadcrumb
82- const currentSectionTitle = computed (() => headerLinks .value [0 ].children .find (link => path .value .includes (link .to ))?.label || findPageBreadcrumb (navigation .value , path .value ).slice (- 1 )[0 ].title )
82+ const currentSectionTitle = computed (() =>
83+ headerLinks .value [0 ]?.children ?.find (link => path .value .includes (link .to ))?.label
84+ || findPageBreadcrumb (navigation .value , path .value ).slice (- 1 )[0 ]?.title
85+ || ' ' )
8386
8487const breadcrumb = computed (() => {
8588 const links = mapContentNavigation (findPageBreadcrumb (navigation .value , path .value )).map (link => ({
Original file line number Diff line number Diff line change 11import type { Sponsor , SponsorType } from '#shared/types'
22
33export default cachedEventHandler ( async ( event ) => {
4- const sponsors = await Promise . all ( [
5- fetchGithubSponsors ( event ) ,
6- fetchOpenCollectiveSponsors ( event )
7- ] )
4+ let sponsors : [ Sponsor [ ] , Sponsor [ ] ]
5+ try {
6+ sponsors = await Promise . all ( [
7+ fetchGithubSponsors ( event ) ,
8+ fetchOpenCollectiveSponsors ( event )
9+ ] )
10+ } catch ( e ) {
11+ console . warn ( '[sponsors] Failed to load sponsor data, returning empty tiers:' , e )
12+ sponsors = [ [ ] , [ ] ]
13+ }
814
915 const sponsorsByTier : Record < SponsorType , Array < Sponsor > > = {
1016 diamond : [ ] ,
Original file line number Diff line number Diff line change @@ -44,7 +44,8 @@ async function npmFetch<T>(url: string): Promise<T | null> {
4444 }
4545 }
4646
47- console . error ( `Failed to fetch ${ url } after ${ maxRetries } retries: ${ lastError } ` )
47+ const wasRateLimited = lastError ?. status === 429 || lastError ?. statusCode === 429
48+ console [ wasRateLimited ? 'warn' : 'error' ] ( `Failed to fetch ${ url } after ${ maxRetries } retries: ${ lastError } ` )
4849
4950 return null
5051}
@@ -101,9 +102,11 @@ export const npm = {
101102 }
102103 }
103104
104- // Fetch scoped packages individually (not supported in bulk queries)
105+ // Fetch scoped packages individually (not supported in bulk queries).
106+ // Small delay between calls to avoid npm registry 429s during full prerender/build.
105107 for ( const pkg of scopedPackages ) {
106108 result [ pkg ] = await this . fetchPackageStats ( pkg , period )
109+ await new Promise ( r => setTimeout ( r , 75 ) )
107110 }
108111
109112 return result
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ export interface OpenCollectiveSponsor {
3939}
4040
4141export async function fetchOpenCollectiveSponsors ( event : H3Event ) : Promise < OpenCollectiveSponsor [ ] > {
42+ if ( ! useRuntimeConfig ( event ) . openCollective . apiKey ) {
43+ console . warn ( '[sponsors] Skipping Open Collective: NUXT_OPEN_COLLECTIVE_API_KEY is not set' )
44+ return [ ]
45+ }
46+
4247 const key = `sponsors:opencollective`
4348 const cached = await kv . get < OpenCollectiveSponsor [ ] > ( key )
4449 if ( cached ) {
@@ -150,6 +155,11 @@ export async function fetchOpenCollectiveSponsors(event: H3Event): Promise<OpenC
150155}
151156
152157export const fetchGithubSponsors = async ( event : H3Event ) : Promise < Sponsor [ ] > => {
158+ if ( ! useRuntimeConfig ( event ) . github . token ) {
159+ console . warn ( '[sponsors] Skipping GitHub sponsors: NUXT_GITHUB_TOKEN is not set' )
160+ return [ ]
161+ }
162+
153163 const response : Sponsor [ ] = [ ]
154164 const first = 100
155165 let cursor : string | null = null
You can’t perform that action at this time.
0 commit comments