vite-plugin-pages-sitemap
TypeScript icon, indicating that this package has built-in type declarations

1.6.1 • Public • Published

vite-plugin-pages-sitemap

npm version monthly downloads types license

vite-plugin-pages based sitemap generator

Getting Started

Vue

Install:

npm install -D vite-plugin-pages
npm install -D vite-plugin-pages-sitemap
npm install vue-router@next

Vite config

Add to your vite.config.js:

import Pages from 'vite-plugin-pages'
import generateSitemap from 'vite-plugin-pages-sitemap'

export default {
  plugins: [
    // ...
    Pages({
      onRoutesGenerated: routes => (generateSitemap({ routes })),
    }),
  ],
}

Dynamic routes

To generate dynamic routes, you can add them manually:

export default {
  plugins: [
    // ...
    Pages({
      onRoutesGenerated: async (routes) => {
        const users = await api.get('/users')
        const dynamicRoutes = users.map(user => `/users/${user.name}`)
        generateSitemap({ routes: [...routes, ...dynamicRoutes] })
      },
    }),
  ],
}

You can find a working example in example folder.

hostname

  • Type: string
  • Default: 'http://localhost/'

Base URI.

routes

  • 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.

exclude

  • Type: string[]
  • Default: []

Excluded routes for sitemap.

filename

  • Type: string
  • Default: 'sitemap'

File name.

dest

  • Type: string
  • Default: 'public'

Destination path.

changefreq

  • Type: string
  • Default: 'daily'

Change frequency option for sitemap.

priority

  • Type: number
  • Default: 1

Priority option for sitemap.

lastmod

  • Type: Date
  • Default: new Date()

Last modification option for sitemap.

readable

  • Type: boolean
  • Default: false

Converts XML into a human readable format

nuxtStyle

  • Type: boolean
  • Default: false

Is Nuxt.js style route naming.

allowRobots

  • Type: boolean
  • Default: true

Allow robots crawl (in robots.txt file).

License

MIT License © 2022 jbaubree

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-pages-sitemap

Weekly Downloads

1,293

Version

1.6.1

License

MIT

Unpacked Size

309 kB

Total Files

6

Last publish

Collaborators

  • jbaubree