Skip to content

Commit

Permalink
feat(prerender): basic ignore support
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 9, 2022
1 parent 541b0b0 commit a6cbbbe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const NitroDefaults: NitroConfig = {
routes: {},
prerender: {
crawlLinks: false,
ignore: [],
routes: []
},

Expand Down
3 changes: 3 additions & 0 deletions src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export async function prerender (nitro: Nitro) {
const canPrerender = (route: string = '/') => {
if (generatedRoutes.has(route)) { return false }
if (route.length > 250) { return false }
for (const ignore of nitro.options.prerender.ignore) {
if (route.startsWith(ignore)) { return false }
}
return true
}

Expand Down
1 change: 1 addition & 0 deletions src/types/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export interface NitroOptions {
devErrorHandler: NitroErrorHandler
prerender: {
crawlLinks: boolean
ignore: string[]
routes: string[]
}

Expand Down
3 changes: 3 additions & 0 deletions test/fixture/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default defineNitroConfig({
],
prerender: {
crawlLinks: true,
ignore: [
// '/api/param/'
],
routes: [
'/prerender',
'/404'
Expand Down

0 comments on commit a6cbbbe

Please sign in to comment.