Skip to content

Commit 21e765f

Browse files
committed
feat: pre-render all non-dynamic pages
1 parent 00f60a2 commit 21e765f

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
- [x] Zero-config required
1717
- [x] Auto-import Ionic components and composables throughout your app
1818
- [x] Ionic Router integration
19+
- [x] Pre-rendering auto-configuration
1920
- [ ] Capacitor implementation confirmed working
20-
- [ ] Pre-rendering auto-configuration
2121

2222
## Quick setup
2323

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
},
5959
"devDependencies": {
6060
"@nuxt/module-builder": "latest",
61+
"@nuxt/schema": "3.0.0-rc.4",
6162
"@nuxtjs/eslint-config-typescript": "latest",
6263
"@release-it/conventional-changelog": "latest",
6364
"@types/node": "latest",

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { fileURLToPath } from 'url'
22
import { join, resolve } from 'pathe'
33
import { defineUnimportPreset } from 'unimport'
44
import { defineNuxtModule, addComponent, addPlugin } from '@nuxt/kit'
5+
import type { NuxtPage } from '@nuxt/schema'
56

67
export interface ModuleOptions {
78
integrations?: {
@@ -101,6 +102,28 @@ export default defineNuxtModule<ModuleOptions>({
101102
'nuxt/dist/app/plugins/router'
102103
)
103104
)
105+
106+
// Add all pages to be prerendered
107+
const routes: string[] = []
108+
109+
nuxt.hook('pages:extend', pages => {
110+
routes.length = 0
111+
function processPages(pages: NuxtPage[]) {
112+
for (const page of pages) {
113+
if (!page.path.includes(':')) {
114+
routes.push(page.path)
115+
}
116+
if (page.children) {
117+
processPages(page.children)
118+
}
119+
}
120+
}
121+
processPages(pages)
122+
})
123+
124+
nuxt.hook('nitro:build:before', nitro => {
125+
nitro.options.prerender.routes = routes
126+
})
104127
})
105128

106129
// Remove vue-router types

0 commit comments

Comments
 (0)