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
This commit is contained in:
Johan Stenehall 2014-03-04 11:52:27 +01:00
parent be8b9cf092
commit 825ba4fb82
2 changed files with 13 additions and 1 deletions

View File

@ -461,11 +461,13 @@ coreHelpers.meta_title = function (options) {
blog; blog;
if (_.isString(this.relativeUrl)) { if (_.isString(this.relativeUrl)) {
blog = config.theme();
if (!this.relativeUrl || this.relativeUrl === '/' || this.relativeUrl === '' || this.relativeUrl.match(/\/page/)) { if (!this.relativeUrl || this.relativeUrl === '/' || this.relativeUrl === '' || this.relativeUrl.match(/\/page/)) {
blog = config.theme();
title = blog.title; title = blog.title;
} else if (this.post) { } else if (this.post) {
title = this.post.title; title = this.post.title;
} else if (this.tag) {
title = this.tag.name + ' - ' + blog.title;
} }
} }

View File

@ -865,6 +865,16 @@ describe('Core Helpers', function () {
done(); done();
}).then(null, 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 () { describe("meta_description helper", function () {