Merge pull request #3611 from ErisDS/author-classes

Adding missing body class for author pages
This commit is contained in:
Sebastian Gierlinger 2014-08-06 09:37:06 +02:00
commit 22171fd058
2 changed files with 13 additions and 2 deletions

View File

@ -411,6 +411,11 @@ coreHelpers.body_class = function (options) {
classes.push('tag-' + this.tag.slug);
}
if (this.author !== undefined) {
classes.push('author-template');
classes.push('author-' + this.author.slug);
}
if (tags) {
classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; }));
}

View File

@ -399,21 +399,27 @@ describe('Core Helpers', function () {
helpers.body_class.call({relativeUrl: '/a-post-title', post: {}}),
helpers.body_class.call({relativeUrl: '/page/4'}),
helpers.body_class.call({relativeUrl: '/tag/foo', tag: { slug: 'foo'}}),
helpers.body_class.call({relativeUrl: '/tag/foo/page/2', tag: { slug: 'foo'}})
helpers.body_class.call({relativeUrl: '/tag/foo/page/2', tag: { slug: 'foo'}}),
helpers.body_class.call({relativeUrl: '/author/bar', author: { slug: 'bar'}}),
helpers.body_class.call({relativeUrl: '/author/bar/page/2', author: { slug: 'bar'}})
]).then(function (rendered) {
rendered.length.should.equal(5);
rendered.length.should.equal(7);
should.exist(rendered[0]);
should.exist(rendered[1]);
should.exist(rendered[2]);
should.exist(rendered[3]);
should.exist(rendered[4]);
should.exist(rendered[5]);
should.exist(rendered[6]);
rendered[0].string.should.equal('home-template');
rendered[1].string.should.equal('post-template');
rendered[2].string.should.equal('archive-template');
rendered[3].string.should.equal('tag-template tag-foo');
rendered[4].string.should.equal('archive-template tag-template tag-foo');
rendered[5].string.should.equal('author-template author-bar');
rendered[6].string.should.equal('archive-template author-template author-bar');
done();
}).catch(done);