Skip to content

Commit c8f3dc4

Browse files
committed
fix: type test
1 parent 480e07e commit c8f3dc4

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

nuxt.config.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,10 @@ export default defineNuxtConfig({
8585
routeRules: {
8686
'/': { prerender: true },
8787
'/opensearch.xml': { isr: true },
88-
'/**': {
89-
isr: {
90-
expiration: 60,
91-
fallback: 'spa.prerender-fallback.html',
92-
},
93-
},
88+
'/**': { isr: getISRConfig(60, true) },
9489
'/api/**': { isr: 60 },
9590
'/200.html': { prerender: true },
96-
'/package/**': {
97-
isr: {
98-
expiration: 60,
99-
fallback: 'spa.prerender-fallback.html',
100-
},
101-
},
91+
'/package/**': { isr: getISRConfig(60, true) },
10292
'/:pkg/.well-known/skills/**': { isr: 3600 },
10393
'/:scope/:pkg/.well-known/skills/**': { isr: 3600 },
10494
// never cache
@@ -290,3 +280,15 @@ export default defineNuxtConfig({
290280
dirs: ['~/composables', '~/composables/*/*.ts'],
291281
},
292282
})
283+
284+
function getISRConfig(expirationSeconds: number, fallback = false) {
285+
if (fallback) {
286+
return {
287+
expiration: expirationSeconds,
288+
fallback: 'spa.prerender-fallback.html',
289+
} as { expiration: number }
290+
}
291+
return {
292+
expiration: expirationSeconds,
293+
}
294+
}

0 commit comments

Comments
 (0)