From 7f9d10a62de5209163a1b137fd0861118905fe60 Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Sat, 24 Jan 2015 21:13:23 +1300 Subject: [PATCH] Assign a higher priority to featured posts in the sitemap Closes #4792 - Made priority be 0.8 (as it currently is) for standard posts - Made featured posts have a priority of 0.9 - Split the current test into two to check both above scenarios --- core/server/data/sitemap/post-generator.js | 6 +++--- core/test/integration/sitemap_spec.js | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/server/data/sitemap/post-generator.js b/core/server/data/sitemap/post-generator.js index b2c036b033..d981c9fc88 100644 --- a/core/server/data/sitemap/post-generator.js +++ b/core/server/data/sitemap/post-generator.js @@ -36,9 +36,9 @@ _.extend(PostMapGenerator.prototype, { return config.urlFor('post', {post: post, permalinks: permalinks}, true); }, - getPriorityForDatum: function () { - // TODO: We could influence this with meta information - return 0.8; + getPriorityForDatum: function (post) { + // give a slightly higher priority to featured posts + return post.featured ? 0.9 : 0.8; }, createUrlNodeFromDatum: function (datum) { diff --git a/core/test/integration/sitemap_spec.js b/core/test/integration/sitemap_spec.js index 4088bc068e..c4bee5c480 100644 --- a/core/test/integration/sitemap_spec.js +++ b/core/test/integration/sitemap_spec.js @@ -415,10 +415,20 @@ describe('Sitemap', function () { }); describe('PostGenerator', function () { - it('uses 0.8 priority for all posts', function () { + it('uses 0.9 priority for featured posts', function () { var generator = new PostGenerator(); - generator.getPriorityForDatum({}).should.equal(0.8); + generator.getPriorityForDatum({ + featured: true + }).should.equal(0.9); + }); + + it('uses 0.8 priority for all other (non-featured) posts', function () { + var generator = new PostGenerator(); + + generator.getPriorityForDatum({ + featured: false + }).should.equal(0.8); }); it('adds an image:image element if post has a cover image', function () {