New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nuxtjs/sitemap

Package Overview
Dependencies
Maintainers
5
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/sitemap - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

15

CHANGELOG.md

@@ -5,2 +5,17 @@ # Change Log

<a name="0.1.0"></a>
# [0.1.0](https://github.com/nuxt-community/sitemap-module/compare/v0.0.5...v0.1.0) (2018-04-16)
### Features
* feat: add gzip compression to sitemap by default ([6cee9bd](https://github.com/nuxt-community/sitemap-module/commit/6cee9bd)), closes [#16](https://github.com/nuxt-community/sitemap-module/issues/16)
### Performance Improvements
* optimize lodash imports ([5e1e68f](https://github.com/nuxt-community/sitemap-module/commit/5e1e68f))
<a name="0.0.5"></a>

@@ -7,0 +22,0 @@ ## [0.0.5](https://github.com/nuxt-community/sitemap-module/compare/v0.0.4...v0.0.5) (2018-04-14)

9

package.json
{
"name": "@nuxtjs/sitemap",
"version": "0.0.5",
"version": "0.1.0",
"description": "Automatically generate or serve dynamic sitemap.xml for Nuxt.js projects",

@@ -19,2 +19,6 @@ "license": "MIT",

},
"engines": {
"node": ">=8.0.0",
"npm": ">=5.0.0"
},
"scripts": {

@@ -39,7 +43,5 @@ "dev": "nuxt test/fixture",

"minimatch": "^3.0.4",
"pify": "^3.0.0",
"sitemap": "^1.13.0"
},
"devDependencies": {
"nuxt": "latest",
"codecov": "latest",

@@ -56,4 +58,5 @@ "eslint": "latest",

"jsdom": "latest",
"nuxt": "latest",
"standard-version": "latest"
}
}

@@ -29,2 +29,3 @@ # Sitemap Module

cacheTime: 1000 * 60 * 15,
gzip: true,
generate: false, // Enable me when using nuxt generate

@@ -81,2 +82,7 @@ exclude: [

### `gzip`
- Default: `true`
Enable the creation of the `.xml.gz` sitemap compressed with gzip.
## Routes

@@ -83,0 +89,0 @@

const { Minimatch } = require('minimatch')
const sm = require('sitemap')
const isHTTPS = require('is-https')
const { unionBy, uniq } = require('lodash')
const unionBy = require('lodash/unionBy')
const uniq = require('lodash/uniq')
const path = require('path')
const fs = require('fs-extra')
const AsyncCache = require('async-cache')
const pify = require('pify')
const { promisify } = require('util')
const { hostname } = require('os')

@@ -18,3 +19,4 @@

routes: [],
cacheTime: 1000 * 60 * 15
cacheTime: 1000 * 60 * 15,
gzip: true
}

@@ -31,4 +33,8 @@

options.pathGzip = (options.gzip) ? `${options.path}.gz` : options.path
const gzipGeneratePath = path.resolve(this.options.srcDir, path.join('static', options.pathGzip))
// Ensure no generated file exists
fs.removeSync(xmlGeneratePath)
fs.removeSync(gzipGeneratePath)

@@ -79,3 +85,8 @@ let staticRoutes = fs.readJsonSync(jsonStaticRoutesPath, { throws: false })

const xml = await sitemap.toXML()
await fs.ensureFile(xmlGeneratePath)
await fs.writeFile(xmlGeneratePath, xml)
if (options.gzip) {
const gzip = await sitemap.toGzip()
await fs.writeFile(gzipGeneratePath, gzip)
}
})()

@@ -86,3 +97,21 @@ }

// Add server middleware
if (options.gzip) {
// Add server middleware for sitemap.xml.gz
this.addServerMiddleware({
path: options.pathGzip,
handler (req, res, next) {
cache.get('routes')
.then(routes => createSitemap(options, routes, req))
.then(sitemap => sitemap.toGzip())
.then(gzip => {
res.setHeader('Content-Type', 'gzip')
res.end(gzip)
}).catch(err => {
next(err)
})
}
})
}
// Add server middleware for sitemap.xml
this.addServerMiddleware({

@@ -119,3 +148,3 @@ path: options.path,

})
cache.get = pify(cache.get)
cache.get = promisify(cache.get)

@@ -141,3 +170,3 @@ return cache

const sitemap = sm.createSitemap(sitemapConfig)
sitemap.toXML = pify(sitemap.toXML)
sitemap.toXML = promisify(sitemap.toXML)

@@ -144,0 +173,0 @@ return sitemap

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc