vite-plugin-pages based sitemap generator
npm install vite-plugin-pages-sitemap



> vite-plugin-pages based sitemap generator
🚨Important Notes🚨
You must use vite-plugin-pages routes generation to use this plugin. If you are not working with vite-plugin-pages, i recommend to use vite-plugin-sitemap.
Install:
``bash`
npm install -D vite-plugin-pages
npm install -D vite-plugin-pages-sitemap
npm install vue-router@next
Add to your vite.config.js:
`js
import Pages from 'vite-plugin-pages'
import generateSitemap from 'vite-plugin-pages-sitemap'
export default {
plugins: [
// ...
Pages({
onRoutesGenerated: routes => (generateSitemap({ routes })),
}),
],
}
`
To generate dynamic routes, you can add them manually:
`js/users/${user.name}
export default {
plugins: [
// ...
Pages({
onRoutesGenerated: async (routes) => {
const users = await api.get('/users')
const dynamicRoutes = users.map(user => )`
generateSitemap({ routes: [...routes, ...dynamicRoutes] })
},
}),
],
}
You can find a working example in example folder.
- Type: { defaultLanguage?: string, languages: string[] }undefined
- Default:
Add i18n support defining alternate links.
defaultLanguage will use this language with / and languages with /language
- Type: string'http://localhost/'
- Default:
Base URI.
- Type: Route[] or/and string[][]
- Default:
Generated routes from vite-plugin-pages or/and strings as paths (ex: ['/user/1', '/user/2']) for manual dynamic routes.
- Type: string[][]
- Default:
Excluded routes for sitemap.
- Type: string'sitemap'
- Default:
File name.
- Type: string'public'
- Default:
Destination path.
- Type: string'daily'
- Default:
Change frequency option for sitemap.
- Type: number1
- Default:
Priority option for sitemap.
- Type: Datenew Date()
- Default:
Last modification option for sitemap.
- Type: booleanfalse
- Default:
Converts XML into a human readable format
- Type: booleanfalse
- Default:
Is Nuxt.js style route naming.
- Type: booleantrue`
- Default:
Allow robots crawl (in robots.txt file).
MIT License © 2022 jbaubree