diff --git a/lib/generator.js b/lib/generator.js index 909ed22..c443135 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -13,6 +13,16 @@ const seoFriendlySitemap = function(locals) { render = require('./render')(locals, config), sitemaps = _.concat(posts.get(), pages.get(), categories.get(), tags.get(), xsl.get()) + if (config.sitemap.additionalUrl) { + sitemaps.push( + Promise.resolve({ + filename: config.sitemap.additionalUrl.filename, + lastModification: config.sitemap.additionalUrl.lastModification, + isInIndexSitemap: true + }) + ) + } + return Promise.all(sitemaps) .filter(common.isDefined) .then(indexSitemap.get) diff --git a/lib/render.js b/lib/render.js index af69631..014f310 100644 --- a/lib/render.js +++ b/lib/render.js @@ -29,6 +29,7 @@ const render = function(locals, config) { } const renderSitemaps = function(sitemap) { + if (!sitemap.template) return const templateFilePath = path.join(viewPath, sitemap.template) return Promise.join(sitemap, templateFilePath, common.getFileContent(templateFilePath), getCompiledContent) } diff --git a/test/allSitemaps.test.js b/test/allSitemaps.test.js index 8529321..727f3d0 100644 --- a/test/allSitemaps.test.js +++ b/test/allSitemaps.test.js @@ -67,7 +67,11 @@ describe('SEO-friendly sitemap generator: All Sitemaps', function() { it('should generate all sitemap files if posts, pages, categories and tags are defined', function() { hexo.config.sitemap = { path: 'sitemap.xml', - beautify: false + beautify: false, + additionalUrl: { + filename: 'web-story-sitemap.xml', + lastModification: moment.utc([2014, 11, 10, 9]).toDate() + } } const expectedDirectory = path.join(__dirname, 'expected'), diff --git a/test/expected/full-index-sitemap.xml b/test/expected/full-index-sitemap.xml index 600ce18..97a34a7 100644 --- a/test/expected/full-index-sitemap.xml +++ b/test/expected/full-index-sitemap.xml @@ -21,5 +21,10 @@ 2015-01-01T08:00:00.000Z + + http://yoursite.com/web-story-sitemap.xml + 2014-12-10T09:00:00.000Z + + \ No newline at end of file diff --git a/test/splittedPostSitemaps.test.js b/test/splittedPostSitemaps.test.js index 5abebea..31dae0e 100644 --- a/test/splittedPostSitemaps.test.js +++ b/test/splittedPostSitemaps.test.js @@ -84,7 +84,7 @@ describe('SEO-friendly sitemap generator: All Sitemaps with splitted post sitema expectedTagSitemap = fs.readFileAsync(expectedTagFilePath, readFileOptions), checkAssertions = function(result) { expect(Array.isArray(result)).toBe(true) - console.log('caca', result) + const indexSitemap = _.find(result, { path: 'sitemap.xml' }), postSitemap = _.find(result, { path: 'post-sitemap-1.xml' }), pageSitemap = _.find(result, { path: 'page-sitemap.xml' }),