From e45dfd63ba7cc5f6d99d98b758ae5084113d5eac Mon Sep 17 00:00:00 2001 From: Ezequiel Rubio Date: Mon, 26 Jun 2017 00:04:47 +0200 Subject: [PATCH] Add lastmod to buildSitemapIndex --- lib/sitemap.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/sitemap.js b/lib/sitemap.js index df1e135d..211f7109 100644 --- a/lib/sitemap.js +++ b/lib/sitemap.js @@ -528,6 +528,7 @@ function createSitemapIndex(conf) { */ function buildSitemapIndex(conf) { var xml = []; + var lastmod; xml.push(''); if (conf.xslUrl) { @@ -542,10 +543,21 @@ function buildSitemapIndex(conf) { xml.push('') } + 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(''); xml.push('' + url + ''); + if(lastmod) { + xml.push('' + lastmod + ''); + } xml.push(''); });