Skip to content

Commit

Permalink
Merge pull request #115 from erubio/master
Browse files Browse the repository at this point in the history
Add lastmod to buildSitemapIndex
  • Loading branch information
ekalinin authored Jun 26, 2017
2 parents 322029b + e45dfd6 commit 8c96fb3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ function createSitemapIndex(conf) {
*/
function buildSitemapIndex(conf) {
var xml = [];
var lastmod;

xml.push('<?xml version="1.0" encoding="UTF-8"?>');
if (conf.xslUrl) {
Expand All @@ -542,10 +543,21 @@ function buildSitemapIndex(conf) {
xml.push('<sitemapindex ' + conf.xmlNs + '>')
}

if(conf.lastmodISO) {
lastmod = conf.lastmodISO;
} else if(conf.lastmodrealtime) {
lastmod = new Date().toISOString();
} else if(conf.lastmod) {
lastmod = new Date(conf.lastmod).toISOString();
}


conf.urls.forEach(function (url) {
xml.push('<sitemap>');
xml.push('<loc>' + url + '</loc>');
if(lastmod) {
xml.push('<lastmod>' + lastmod + '</lastmod>');
}
xml.push('</sitemap>');
});

Expand Down

0 comments on commit 8c96fb3

Please sign in to comment.