Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prerender: hooks #88

Closed
pi0 opened this issue Apr 12, 2022 · 2 comments · Fixed by #299
Closed

prerender: hooks #88

pi0 opened this issue Apr 12, 2022 · 2 comments · Fixed by #299
Labels
enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented Apr 12, 2022

nuxt/nuxt#11786

Most importantly prerender:route hook which can be useful to modify and inspect pretender results. (eg: for service-worker to inject it's script)

@pi0 pi0 added the enhancement New feature or request label Apr 12, 2022
@pi0 pi0 self-assigned this Apr 12, 2022
@pi0 pi0 mentioned this issue May 9, 2022
7 tasks
@pi0 pi0 removed their assignment Jun 16, 2022
@farnabaz
Copy link
Contributor

farnabaz commented Jun 17, 2022

We have a prerender:route hoo, but it is not useful. (Changing route data does not affect on generated content)

await nitro.hooks.callHook('prerender:route', _route)

But this should move into generateRoute function, before persisting content into file

nitro/src/prerender.ts

Lines 66 to 68 in cbc7ba3

_route.fileName = isImplicitHTML ? route + '/index.html' : routeWithIndex
const filePath = join(nitro.options.output.publicDir, _route.fileName)
await writeFile(filePath, _route.contents)

WDYT @pi0

@pi0
Copy link
Member Author

pi0 commented Jun 20, 2022

Nice find @farnabaz. prerender:route is called outside as for generic error handling and stats purposes. We might introduce another predenrer hook and use before writeFileCall to allow extending to skipping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants