mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 00:15:11 +03:00
parent
353e11dafb
commit
0b5de14900
@ -9,19 +9,31 @@ function getTitle(data, root) {
|
||||
pageString = '';
|
||||
|
||||
if (pagination && pagination.total > 1) {
|
||||
pageString = ' - Page ' + pagination.page;
|
||||
pageString = ' (Page ' + pagination.page + ')';
|
||||
}
|
||||
|
||||
// If there's a specific meta title
|
||||
if (data.meta_title) {
|
||||
title = data.meta_title;
|
||||
// Home title
|
||||
} else if (_.includes(context, 'home')) {
|
||||
title = blogTitle;
|
||||
// Author title, paged
|
||||
} else if (_.includes(context, 'author') && data.author && _.includes(context, 'paged')) {
|
||||
title = data.author.name + ' - ' + blogTitle + pageString;
|
||||
// Author title, index
|
||||
} else if (_.includes(context, 'author') && data.author) {
|
||||
title = data.author.name + pageString + ' - ' + blogTitle;
|
||||
title = data.author.name + ' - ' + blogTitle;
|
||||
// Tag title, paged
|
||||
} else if (_.includes(context, 'tag') && data.tag && _.includes(context, 'paged')) {
|
||||
title = data.tag.meta_title || data.tag.name + ' - ' + blogTitle + pageString;
|
||||
// Tag title, index
|
||||
} else if (_.includes(context, 'tag') && data.tag) {
|
||||
title = data.tag.meta_title || data.tag.name + pageString + ' - ' + blogTitle;
|
||||
title = data.tag.meta_title || data.tag.name + ' - ' + blogTitle;
|
||||
// Post title
|
||||
} else if ((_.includes(context, 'post') || _.includes(context, 'page')) && data.post) {
|
||||
title = data.post.meta_title || data.post.title;
|
||||
// Fallback
|
||||
} else {
|
||||
title = blogTitle + pageString;
|
||||
}
|
||||
|
@ -53,14 +53,14 @@ describe('getTitle', function () {
|
||||
name: 'Author Name'
|
||||
}
|
||||
}, {
|
||||
context: ['author'],
|
||||
context: ['author', 'paged'],
|
||||
pagination: {
|
||||
total: 40,
|
||||
page: 3
|
||||
}
|
||||
});
|
||||
|
||||
title.should.equal('Author Name - Page 3 - My blog title 2');
|
||||
title.should.equal('Author Name - My blog title 2 (Page 3)');
|
||||
});
|
||||
|
||||
it('should return tag name - blog title if on data tag page no meta_title', function () {
|
||||
@ -75,7 +75,7 @@ describe('getTitle', function () {
|
||||
title.should.equal('Tag Name - My blog title 3');
|
||||
});
|
||||
|
||||
it('should return tag name - page - blog title if on data tag page no meta_title', function () {
|
||||
it('should return tag name - blog title if on data tag page no meta_title (Page #)', function () {
|
||||
localSettingsCache.title = 'My blog title 3';
|
||||
|
||||
var title = getTitle({
|
||||
@ -83,14 +83,14 @@ describe('getTitle', function () {
|
||||
name: 'Tag Name'
|
||||
}
|
||||
}, {
|
||||
context: ['tag'],
|
||||
context: ['tag', 'paged'],
|
||||
pagination: {
|
||||
total: 40,
|
||||
page: 39
|
||||
}
|
||||
});
|
||||
|
||||
title.should.equal('Tag Name - Page 39 - My blog title 3');
|
||||
title.should.equal('Tag Name - My blog title 3 (Page 39)');
|
||||
});
|
||||
|
||||
it('should return tag meta_title if in tag data', function () {
|
||||
@ -177,6 +177,6 @@ describe('getTitle', function () {
|
||||
}
|
||||
});
|
||||
|
||||
title.should.equal('My blog title 4 - Page 35');
|
||||
title.should.equal('My blog title 4 (Page 35)');
|
||||
});
|
||||
});
|
||||
|
@ -37,7 +37,7 @@ describe('{{meta_title}} helper', function () {
|
||||
);
|
||||
|
||||
should.exist(rendered);
|
||||
String(rendered).should.equal('Ghost - Page 2');
|
||||
String(rendered).should.equal('Ghost (Page 2)');
|
||||
});
|
||||
|
||||
it('returns correct title for a post', function () {
|
||||
@ -88,7 +88,7 @@ describe('{{meta_title}} helper', function () {
|
||||
);
|
||||
|
||||
should.exist(rendered);
|
||||
String(rendered).should.equal('Rasper Red - Page 2 - Ghost');
|
||||
String(rendered).should.equal('Rasper Red - Ghost (Page 2)');
|
||||
});
|
||||
|
||||
it('uses tag meta_title to override default response on tag page', function () {
|
||||
@ -128,7 +128,7 @@ describe('{{meta_title}} helper', function () {
|
||||
);
|
||||
|
||||
should.exist(rendered);
|
||||
String(rendered).should.equal('Donald Duck - Page 2 - Ghost');
|
||||
String(rendered).should.equal('Donald Duck - Ghost (Page 2)');
|
||||
});
|
||||
|
||||
it('returns correctly escaped title of a post', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user