vue-router-sitemap

Module to generate a sitemap for vue-router configuration
3,327 111
Install
npm install vue-router-sitemap
Latest Version:0.0.4
License:MIT
Last Updated:Dec 7, 2022
Links: GitHub  ·  npm
Maintainer: 40818419

vue-router-sitemap

Generate sitemap.xml by vue-router configuration

Install

npm i --save vue-router-sitemap

Example usage

// router.js

import VueRouter from 'vue-router';

export const router: VueRouter = new VueRouter(
  {
    routes: [
      {
        path:      '/',
        name:      'index',
        component: Index,
      },
    ],
  },
);
// sitemapMiddleware.js

import VueRouterSitemap      from 'vue-router-sitemap';
import path                  from 'path';
import { router }            from 'router';

...
export const sitemapMiddleware = () => {
  return (req, res) => {
    res.set('Content-Type', 'application/xml');

    const staticSitemap = path.resolve('dist/static', 'sitemap.xml');
    const filterConfig = {
      isValid: false,
      rules: [
        /\/example-page/,
        /\*/,
      ],
    };

    new VueRouterSitemap(router).filterPaths(filterConfig).build('http://example.com').save(staticSitemap);

    return res.sendFile(staticSitemap);
  };
};

app.get('/sitemap.xml', sitemapMiddleware());
...

License

MIT

Related Packages

vue-router-tiny

A router for Vue.js

562 3
@kitbag/router

Type safe router for Vue.js

65,953
@deppon/deppon-router

Vue Router 4 wrapper package

19,227
vue-route-middleware

Make complex route middleware logic look easy and readable!

13,280 18

Version History

Version Released License
0.0.4 MIT
0.0.3 MIT
0.0.2 MIT
0.0.1 MIT