ekoeryanto / vuepress-plugin-sitemap

Sitemap generator plugin for vuepress.
MIT License
93 stars 19 forks source link

Feature Request: exclude from sitemap with frontmatter #18

Closed brianmercer closed 4 years ago

brianmercer commented 5 years ago

Please consider adding a method to exclude pages from the sitemap through a frontmatter tag. i.e.

---
Title: Page That I Don't Want In the Sitemap
sitemap: false
---
hi-kato commented 5 years ago

This is nice idea.

Since I want to exclude "404. html", I would like to propose another method.

In proposal

add to Options

I thought it would be nice to add 「exclude」 to Options.

exclude:
  type: array
  required: false
  default: []
  example: 
    exclude:[
        '/404.html',
        '/hoge/'
    ]

Modify index.js

  1. Add option(exclude) as follows in this part
      const {
        urls = [],
        hostname,
        cacheTime = 600,
        xslUrl,
        xmlNs,
        outFile = 'sitemap.xml',
        changefreq = 'daily',
    +   exclude = [],
        ...others
      } = options
  2. Modify this part as follows

      pagesMap.forEach((page, url) => {
    -   sitemap.add({ url, ...page })
    +   if (!exclude.includes(url)) sitemap.add({ url, ...page })
      })
ekoeryanto commented 5 years ago

@hi-kato hit a PR, please

dsturm commented 4 years ago

Hey @ekoeryanto, would you please release a new version (to npm) for this new feature?

ekoeryanto commented 4 years ago

done