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

[Documentation Request] Extending the HTML template #21593

Closed
3 of 4 tasks
Hebilicious opened this issue Jun 15, 2023 · 4 comments · Fixed by #21615
Closed
3 of 4 tasks

[Documentation Request] Extending the HTML template #21593

Hebilicious opened this issue Jun 15, 2023 · 4 comments · Fixed by #21615

Comments

@Hebilicious
Copy link
Member

Describe the feature

How to extend the HTML template should be explained clearly in the docs, with example for the most common things.

We should document how to use the following Nitro hooks at the same time.

export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('render:html', (html, { event }) => { console.log({ html }) })
  nitroApp.hooks.hook('render:response', (response, { event }) => { console.log(response) })
})

This would fix #14195

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@Hebilicious Hebilicious changed the title [Documenation Request] Extending the HTML template [Documentation Request] Extending the HTML template Jun 15, 2023
@danielroe
Copy link
Member

A PR would be very welcome ❤️ 🙏

@huang-julien
Copy link
Member

huang-julien commented Jun 16, 2023

BTW is it me or don't we have any types for nitro hooks ?

@danielroe
Copy link
Member

They exist in nitro. Worth checking the cause if the types aren't flowing through

@Lehoczky
Copy link
Contributor

They exist in nitro. Worth checking the cause if the types aren't flowing through

There is a TODO comment for this in nitro's source code:

export interface NitroApp {
  h3App: H3App;
  router: Router;
  // TODO: Type hooks and allow extending
  hooks: Hookable;
  localCall: ReturnType<typeof createCall>;
  localFetch: ReturnType<typeof createLocalFetch>;
}

https://github.com/unjs/nitro/blob/88b4e11854c6a84c764bf64329f8e50a946b03b8/src/runtime/app.ts#L29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants