Socket
Socket
Sign inDemoInstall

gulp-sitemap

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-sitemap - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

17

index.js
'use strict';
var chalk = require('chalk');
var defaults = require('lodash.defaults');
var gutil = require('gulp-util');
var path = require('path');
var gutil = require('gulp-util');
var through = require('through2');
var defaults = require('lodash.defaults');
var pluginName = 'gulp-sitemap';
var sitemap = require('./lib/sitemap');
var pluginName = 'gulp-sitemap';
var chalk = require('chalk');
module.exports = function (options) {
var config = defaults(options || {}, {
changefreq: null,
changefreq: undefined,
fileName: 'sitemap.xml',

@@ -17,3 +18,3 @@ lastmod: null,

newLine: gutil.linefeed,
priority: null,
priority: undefined,
spacing: ' ',

@@ -32,5 +33,5 @@ verbose: false

msg = chalk.magenta('changeFreq') + ' has been deprecated. Please use ' + chalk.cyan('changefreq');
gutil.log(pluginName, msg);
config.changefreq = options.changeFreq;
throw new gutil.PluginError(pluginName, msg);
}
// site url should have a trailing slash
if (config.siteUrl.slice(-1) !== '/') {

@@ -37,0 +38,0 @@ config.siteUrl = config.siteUrl + '/';

'use strict';
var defaults = require('lodash.defaults');
var find = require('lodash.find');
var includes = require('lodash.includes');
var multimatch = require('multimatch');
var slash = require('slash');
var multimatch = require('multimatch');
var includes = require('lodash.includes');
var pick = require('lodash.pick');

@@ -15,24 +18,15 @@ //TODO: export this to an external module

function getEntryConfig(file, fileLastMod, config) {
var lastmod = config.lastmod;
var priority = config.priority;
var changefreq = config.changefreq;
var mappingsForFile = find(config.mappings, function(item) {
return multimatch(file, item.pages).length > 0;
}) || {};
config.mappings.some(function (item) {
if (multimatch(file, item.pages).length) {
if (typeof item.lastmod !== 'undefined') {
lastmod = item.lastmod;
}
if (typeof item.priority !== 'undefined') {
priority = item.priority;
}
if (typeof item.changefreq !== 'undefined') {
changefreq = item.changefreq;
}
return true;
}
return false;
});
var properties = ['lastmod', 'priority', 'changefreq', 'hreflang'];
if (lastmod === null) {
lastmod = fileLastMod || Date.now();
var entry = defaults(
pick(mappingsForFile, properties),
pick(config, properties)
);
if (entry.lastmod === null) {
entry.lastmod = fileLastMod || Date.now();
}

@@ -43,10 +37,7 @@

//url location. Use slash to convert windows \\ or \ to /
var loc = config.siteUrl + slash(relativeFile);
var adjustedFile = slash(relativeFile);
entry.loc = config.siteUrl + adjustedFile;
entry.file = adjustedFile;
return {
loc: loc,
lastmod: lastmod,
changefreq: changefreq,
priority: priority
};
return entry;
}

@@ -70,2 +61,4 @@

var loc = entry.loc;
var hreflang = entry.hreflang;
var file = entry.file;

@@ -87,2 +80,9 @@ var returnArr = [

}
if (hreflang && hreflang.length > 0) {
hreflang.forEach(function(item) {
var href = item.getHref(config.siteUrl, file, item.lang, loc);
var tag = '<xhtml:link rel="alternate" hreflang="' + item.lang + '" href="' + href + '" />';
returnArr.push(config.spacing + config.spacing + tag);
});
}
returnArr.push(config.spacing + '</url>');

@@ -94,3 +94,3 @@ return returnArr.join(config.newLine);

return header
.concat(entries.map(function (entry) {
.concat(entries.map(function(entry) {
return processEntry(entry, config);

@@ -122,4 +122,4 @@ }))

exports.getEntryConfig = getEntryConfig;
exports.isChangefreqValid = isChangefreqValid;
exports.prepareSitemap = prepareSitemap;
exports.processEntry = processEntry;
exports.isChangefreqValid = isChangefreqValid;
{
"name": "gulp-sitemap",
"version": "2.2.0",
"version": "3.0.0",
"description": "Generate a search engine friendly sitemap.xml using a Gulp stream",

@@ -18,3 +18,3 @@ "repository": "pgilad/gulp-sitemap",

"engines": {
"node": ">=0.10.0"
"node": ">=4.0.0"
},

@@ -38,6 +38,8 @@ "scripts": {

"dependencies": {
"chalk": "^1.0.0",
"gulp-util": "^3.0.4",
"lodash.defaults": "^3.1.1",
"lodash.includes": "^3.1.2",
"chalk": "^1.1.1",
"gulp-util": "^3.0.7",
"lodash.defaults": "^4.0.1",
"lodash.find": "^4.0.2",
"lodash.includes": "^4.0.1",
"lodash.pick": "^4.0.1",
"multimatch": "^2.0.0",

@@ -51,4 +53,4 @@ "slash": "^1.0.0",

"mocha": "^2.2.4",
"should": "^7.0.2"
"should": "^8.2.1"
}
}

@@ -86,3 +86,3 @@ # [gulp](https://github.com/wearefractal/gulp)-sitemap

Default: `null`
Default: `undefined`

@@ -101,3 +101,3 @@ Valid Values: `['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never']`

Default: `null`
Default: `undefined`

@@ -166,3 +166,9 @@ Valid Values: `0.0` to `1.0`

priority: 0.5,
lastmod: Date.now()
lastmod: Date.now(),
hreflang: [{
lang: 'ru',
getHref: function(siteUrl, file, lang, loc) {
return 'http://www.amazon.ru/' + file;
}
}]
},

@@ -176,6 +182,6 @@ //....

- Only the first match will apply, so consequent matches for the filename will not apply.
- Possible attributes to override: `changefreq`, `priority` and `lastmod`.
- Possible attributes to set: `hreflang`, `changefreq`, `priority` and `lastmod`.
- All rules applying to [options](#options) apply to the attributes that can overridden.
#### pages
##### pages

@@ -194,2 +200,18 @@ Type: `array`

##### hreflang
Matching pages can get their `hreflang` tags set using this option.
The input is an array like so:
```js
hreflang: [{
lang: 'ru',
getHref: function(siteUrl, file, lang, loc) {
// return href src for the hreflang. For example:
return 'http://www.amazon.ru/' + file;
}
}]
```
#### verbose

@@ -196,0 +218,0 @@

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