mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Updated meta helpers to use tag meta data if present
No issue - Tag Meta title and description override default response - Tag Meta title present on all pages - Tag Meta description available only on first page - Updates tests
This commit is contained in:
parent
8ceb896e96
commit
32059812a9
4 changed files with 47 additions and 3 deletions
|
@ -21,8 +21,12 @@ meta_description = function () {
|
|||
description = blog.description;
|
||||
} else if (this.author) {
|
||||
description = /\/page\//.test(this.relativeUrl) ? '' : this.author.bio;
|
||||
} else if (this.tag || /\/page\//.test(this.relativeUrl)) {
|
||||
description = '';
|
||||
} else if (this.tag) {
|
||||
if (/\/page\//.test(this.relativeUrl)) {
|
||||
description = '';
|
||||
} else {
|
||||
description = _.isEmpty(this.tag.meta_description) ? '' : this.tag.meta_description;
|
||||
}
|
||||
} else if (this.post) {
|
||||
description = _.isEmpty(this.post.meta_description) ? '' : this.post.meta_description;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ meta_title = function (options) {
|
|||
} else if (this.author) {
|
||||
title = this.author.name + pageString + ' - ' + blog.title;
|
||||
} else if (this.tag) {
|
||||
title = this.tag.name + pageString + ' - ' + blog.title;
|
||||
title = _.isEmpty(this.tag.meta_title) ? this.tag.name + pageString + ' - ' + blog.title : this.tag.meta_title;
|
||||
} else if (this.post) {
|
||||
title = _.isEmpty(this.post.meta_title) ? this.post.title : this.post.meta_title;
|
||||
} else {
|
||||
|
|
|
@ -64,6 +64,26 @@ describe('{{meta_description}} helper', function () {
|
|||
}).catch(done);
|
||||
});
|
||||
|
||||
it('returns tag meta_description if present for a tag page', function (done) {
|
||||
var tag = {relativeUrl: '/tag/rasper-red', tag: {name: 'Rasper Red', meta_description: 'Rasper is the Cool Red Casper'}};
|
||||
helpers.meta_description.call(tag).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
String(rendered).should.equal('Rasper is the Cool Red Casper');
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('returns empty description on paginated tag page that has meta data', function (done) {
|
||||
var tag = {relativeUrl: '/tag/rasper-red/page/2/', tag: {name: 'Rasper Red', meta_description: 'Rasper is the Cool Red Casper'}};
|
||||
helpers.meta_description.call(tag).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
String(rendered).should.equal('');
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('returns correct description for an author page', function (done) {
|
||||
var author = {relativeUrl: '/author/donald', author: {bio: 'I am a Duck.'}};
|
||||
helpers.meta_description.call(author).then(function (rendered) {
|
||||
|
|
|
@ -84,6 +84,26 @@ describe('{{meta_title}} helper', function () {
|
|||
}).catch(done);
|
||||
});
|
||||
|
||||
it('uses tag meta_title to override default response on tag page', function (done) {
|
||||
var tag = {relativeUrl: '/tag/rasper-red', tag: {name: 'Rasper Red', meta_title: 'Sasper Red'}};
|
||||
helpers.meta_title.call(tag).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
String(rendered).should.equal('Sasper Red');
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('uses tag meta_title to override default response on paginated tag page', function (done) {
|
||||
var tag = {relativeUrl: '/tag/rasper-red', tag: {name: 'Rasper Red', meta_title: 'Sasper Red'}};
|
||||
helpers.meta_title.call(tag).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
String(rendered).should.equal('Sasper Red');
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('returns correct title for an author page', function (done) {
|
||||
var author = {relativeUrl: '/author/donald', author: {name: 'Donald Duck'}};
|
||||
helpers.meta_title.call(author).then(function (rendered) {
|
||||
|
|
Loading…
Add table
Reference in a new issue