Skip to content

Commit 65ced94

Browse files
committed
fix: disable isr rules for package pages
1 parent a6a922d commit 65ced94

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

app/middleware/trailing-slash.global.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@
77
* - /package/vue/ → /package/vue
88
* - /docs/getting-started/?query=value → /docs/getting-started?query=value
99
*/
10-
export default defineNuxtRouteMiddleware(() => {
11-
// if (import.meta.server) {
12-
// const event = useRequestEvent()
13-
// const url = event?.node.req.originalUrl || event?.node.req.url || ''
10+
export default defineNuxtRouteMiddleware(to => {
11+
if (!import.meta.dev) return
1412

15-
// if (url.includes('_payload')) return
16-
// }
17-
18-
// if (to.path !== '' && !to.path.endsWith('/')) {
19-
// return navigateTo(
20-
// {
21-
// path: to.path + '/',
22-
// query: to.query,
23-
// hash: to.hash,
24-
// },
25-
// { replace: true },
26-
// )
27-
// }
28-
return
13+
if (to.path !== '/' && to.path.endsWith('/')) {
14+
return navigateTo(
15+
{
16+
path: to.path.slice(0, -1),
17+
query: to.query,
18+
hash: to.hash,
19+
},
20+
{ replace: true },
21+
)
22+
}
2923
})

nuxt.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ export default defineNuxtConfig({
132132
allowQuery: ['q'],
133133
},
134134
},
135-
// pages
136-
'/package/:name': getISRConfig(60),
137-
'/package/:name/v/:version': getISRConfig(60),
138-
'/package/:org/:name': getISRConfig(60),
139-
'/package/:org/:name/v/:version': getISRConfig(60),
140135
// infinite cache (versioned - doesn't change)
141136
'/package-code/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
142137
'/package-docs/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },

vercel.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://openapi.vercel.sh/vercel.json",
3+
"trailingSlash": false,
34
"redirects": [
45
{
56
"source": "/(.*)",
@@ -9,7 +10,7 @@
910
"value": "chat.npmx.dev"
1011
}
1112
],
12-
"destination": "https://npmx.dev/recharging"
13+
"destination": "https://discord.gg/x9KE5U2q8w"
1314
},
1415
{
1516
"source": "/(.*)",

0 commit comments

Comments
 (0)