Overview
The nuxt-route-meta module adds Nuxt page data to route meta at build time. This allows for accessing meta data at build time in the routes object itself, which is useful for postprocessing routes or for use with the @nuxtjs/sitemap module. This module parses the page files, extracts the meta data, and writes it to the meta field of each route corresponding to the page. It is compatible with Nuxt versions 2 and 3, and has built-in support for TypeScript.
Features
- Parses Nuxt page files and extracts meta data
- Writes meta data to route meta field at build time
- Compatible with Nuxt versions 2 and 3
- Built-in support for TypeScript
Installation
To install the nuxt-route-meta module, follow these steps:
- Add the module to your
nuxt.config.jsfile:
module.exports = {
modules: [
'nuxt-route-meta',
],
}
- Add the required properties to your pages:
export default {
meta: {
// add your meta data here
},
}
That’s it! You can now access the meta data in route.meta from anywhere in your application.
Summary
The nuxt-route-meta module is a useful tool for adding Nuxt page data to route meta at build time. It allows for accessing meta data in the routes object and is compatible with Nuxt versions 2 and 3. With built-in support for TypeScript, it provides an easy way to handle meta data for Nuxt projects.