@nuxtjs/sitemap
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="0.0.3"></a> | ||
## [0.0.3](https://github.com/nuxt/modules/compare/@nuxtjs/sitemap@0.0.2...@nuxtjs/sitemap@0.0.3) (2017-08-03) | ||
### Bug Fixes | ||
* **sitemap:** nuxt rc compability (#104) ([335ae7a](https://github.com/nuxt/modules/commit/335ae7a)) | ||
<a name="0.0.2"></a> | ||
@@ -8,0 +19,0 @@ ## [0.0.2](https://github.com/nuxt/modules/compare/@nuxtjs/sitemap@0.0.1...@nuxtjs/sitemap@0.0.2) (2017-07-25) |
62
index.js
const { Minimatch } = require('minimatch') | ||
const sm = require('sitemap') | ||
const isHTTPS = require('is-https') | ||
const { uniq } = require('lodash') | ||
const { union, uniq } = require('lodash') | ||
const path = require('path') | ||
@@ -45,36 +45,37 @@ const fs = require('fs-extra') | ||
// Extend build | ||
this.extendBuild((config, { isClient, isServer }) => { | ||
if (isClient) { | ||
let staticRoutes = this.nuxt.routes | ||
// Extend routes | ||
this.extendRoutes(routes => { | ||
// Map to path and filter dynamic routes | ||
let staticRoutes = routes | ||
.map(r => r.path) | ||
.filter(r => !r.includes(':') && !r.includes('*')) | ||
// Exclude routes | ||
options.exclude.forEach(pattern => { | ||
const minimatch = new Minimatch(pattern) | ||
minimatch.negate = true | ||
staticRoutes = staticRoutes.filter(route => minimatch.match(route)) | ||
}) | ||
// Exclude routes | ||
options.exclude.forEach(pattern => { | ||
const minimatch = new Minimatch(pattern) | ||
minimatch.negate = true | ||
staticRoutes = staticRoutes.filter(route => minimatch.match(route)) | ||
}) | ||
if (this.options.dev || options.generate) { | ||
// Create a cache for routes | ||
cache = createCache(staticRoutes, options); | ||
} | ||
if (this.options.dev || options.generate) { | ||
// Create a cache for routes | ||
cache = createCache(staticRoutes, options); | ||
} | ||
if (!this.options.dev) { | ||
if (!this.options.dev) { | ||
// TODO on build process only | ||
// Save static routes | ||
fs.ensureDirSync(path.resolve(this.options.buildDir, 'dist')) | ||
fs.writeJsonSync(jsonStaticRoutesPath, staticRoutes) | ||
// TODO on build process only | ||
// Save static routes | ||
fs.ensureDirSync(path.resolve(this.options.buildDir, 'dist')) | ||
fs.writeJsonSync(jsonStaticRoutesPath, staticRoutes) | ||
// TODO on generate process only and not build process | ||
if (options.generate) { | ||
// Generate static sitemap.xml | ||
cache.get('routes') | ||
.then(routes => createSitemap(options, routes)) | ||
.then(sitemap => sitemap.toXML()) | ||
.then(xml => fs.writeFile(xmlGeneratePath, xml)) | ||
// TODO on generate process only and not on build process | ||
if (options.generate) { | ||
// Generate static sitemap.xml | ||
cache.get('routes') | ||
.then(routes => createSitemap(options, routes)) | ||
.then(sitemap => sitemap.toXML()) | ||
.then(xml => fs.writeFile(xmlGeneratePath, xml)) | ||
return | ||
} | ||
return | ||
} | ||
@@ -107,4 +108,3 @@ } | ||
promisifyRoute(options.routes) | ||
.then(routes => staticRoutes.concat(routes)) | ||
.then(routes => uniq(routes)) | ||
.then(routes => union(staticRoutes, routes)) | ||
.then(routes => { | ||
@@ -111,0 +111,0 @@ callback(null, routes) |
{ | ||
"name": "@nuxtjs/sitemap", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
9213