From 825ba4fb82b0bf35066e890f5a62e11a65a48af9 Mon Sep 17 00:00:00 2001 From: Johan Stenehall Date: Tue, 4 Mar 2014 11:52:27 +0100 Subject: [PATCH] Use tag as title on tag pages closes #2328 - added check for tag in coreHelpers.meta_title and use if set - added test for correct title on tag pages Rewritting to tag - blogtitle based on comments from PR --- core/server/helpers/index.js | 4 +++- core/test/unit/server_helpers_index_spec.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index 9c4deb8cdf..3004b5b164 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -461,11 +461,13 @@ coreHelpers.meta_title = function (options) { blog; if (_.isString(this.relativeUrl)) { + blog = config.theme(); if (!this.relativeUrl || this.relativeUrl === '/' || this.relativeUrl === '' || this.relativeUrl.match(/\/page/)) { - blog = config.theme(); title = blog.title; } else if (this.post) { title = this.post.title; + } else if (this.tag) { + title = this.tag.name + ' - ' + blog.title; } } diff --git a/core/test/unit/server_helpers_index_spec.js b/core/test/unit/server_helpers_index_spec.js index 897464e09a..1b61bd933e 100644 --- a/core/test/unit/server_helpers_index_spec.js +++ b/core/test/unit/server_helpers_index_spec.js @@ -865,6 +865,16 @@ describe('Core Helpers', function () { done(); }).then(null, done); }); + + it('can return tag name', function (done) { + var post = {relativeUrl: '/tag/foo', tag: {name: 'foo'}}; + helpers.meta_title.call(post).then(function (rendered) { + should.exist(rendered); + rendered.string.should.equal('foo - Ghost'); + + done(); + }).then(null, done); + }); }); describe("meta_description helper", function () {