Socket
Socket
Sign inDemoInstall

@gridsome/plugin-sitemap

Package Overview
Dependencies
79
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.3 to 0.3.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.3.0](https://github.com/gridsome/gridsome/tree/master/packages/plugin-sitemap/compare/@gridsome/plugin-sitemap@0.2.3...@gridsome/plugin-sitemap@0.3.0) (2020-05-26)
### Features
* **sitemap:** option to include paths ([5a311df](https://github.com/gridsome/gridsome/tree/master/packages/plugin-sitemap/commit/5a311dfdc8775933f7586f00fefa6695e69a096f))
## [0.2.3](https://github.com/gridsome/gridsome/tree/master/packages/plugin-sitemap/compare/@gridsome/plugin-sitemap@0.2.2...@gridsome/plugin-sitemap@0.2.3) (2019-10-25)

@@ -8,0 +19,0 @@

34

index.js

@@ -0,12 +1,14 @@

const path = require('path')
const fs = require('fs-extra')
const micromatch = require('micromatch')
const normalize = p => p.replace(/\/+$/, '') || '/'
module.exports = function (api, options) {
const path = require('path')
const fs = require('fs-extra')
const micromatch = require('micromatch')
const include = options.include.map(normalize)
const exclude = options.exclude.map(normalize)
const normalize = p => p.replace(/\/+$/, '') || '/'
const exclude = options.exclude.slice().map(p => normalize(p))
exclude.push('/404') // allways exclude /404 page
exclude.push('/404') // always exclude 404 page
api.afterBuild(({ queue, config }) => {
api.afterBuild(async ({ queue, config }) => {
if (!config.siteUrl) {

@@ -24,6 +26,13 @@ throw new Error(`Sitemap plugin is missing a required siteUrl config.`)

const staticUrls = options.staticUrls || []
const pages = queue
.filter(page => page.type ? page.type === 'static' : true)
.filter(page => micromatch(page.path, exclude).length < 1)
let pages = queue.filter(page => page.type ? page.type === 'static' : true)
if (include.length) {
pages = pages.filter(page => micromatch(page.path, include).length > 0)
}
if (exclude.length) {
pages = pages.filter(page => micromatch(page.path, exclude).length < 1)
}
console.log(`Generate ${options.output} (${pages.length + staticUrls.length} pages)`)

@@ -51,3 +60,3 @@

return fs.outputFile(filename, sitemap.toString())
await fs.outputFile(filename, sitemap.toString())
})

@@ -60,4 +69,5 @@ }

staticUrls: [],
include: [],
exclude: [],
config: {}
})
{
"version": "0.2.3",
"version": "0.3.0",
"name": "@gridsome/plugin-sitemap",

@@ -26,3 +26,3 @@ "description": "Generate sitemap for Gridsome sites",

},
"gitHead": "644c86f6dbaf103fa8164b002fefb098e68d06e8"
"gitHead": "1a8ce2e4f7ca32bd1f348ac0753289fc7fe81444"
}

@@ -20,3 +20,2 @@ # @gridsome/plugin-sitemap

options: {
cacheTime: 600000, // default
exclude: ['/exclude-me'],

@@ -39,4 +38,53 @@ config: {

### Adding static urls
### Options
#### output
- Type: `string`
- Default `/sitemap.xml`
Your sitemap will be available at `/sitemap.xml`.
#### config
- Type: `object`
Set custom config for specific URLs.
```js
config: {
'/articles/*': {
changefreq: 'weekly',
priority: 0.5
},
'/about': {
changefreq: 'monthly',
priority: 0.7
}
}
```
#### include
- Type: `string[]`
Specify which paths to include in the sitemap. Each path can be a glob pattern.
```js
include: ['/blog', '/blog/**']
```
#### exclude
- Type: `string[]`
Specify which paths to exclude from the sitemap. Each path can be a glob pattern. The `/404` path is always excluded.
#### staticUrls
- Type: `Array`
Add custom URLs to the sitemap.
```js
module.exports = {

@@ -73,4 +121,1 @@ plugins: [

```
Your sitemap will be available at `/sitemap.xml` after your site is built.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc