mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Merge pull request #1117 from halfdan/featured-posts
Add featured class when post is featured
This commit is contained in:
commit
e2cf362395
2 changed files with 14 additions and 1 deletions
|
@ -227,12 +227,17 @@ coreHelpers = function (ghost) {
|
|||
|
||||
ghost.registerThemeHelper('post_class', function (options) {
|
||||
var classes = ['post'],
|
||||
tags = this.post && this.post.tags ? this.post.tags : this.tags || [];
|
||||
tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
|
||||
featured = this.post && this.post.featured ? this.post.featured : this.featured || false;
|
||||
|
||||
if (tags) {
|
||||
classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; }));
|
||||
}
|
||||
|
||||
if (featured) {
|
||||
classes.push('featured');
|
||||
}
|
||||
|
||||
return ghost.doFilter('post_class', classes, function (classes) {
|
||||
var classString = _.reduce(classes, function (memo, item) { return memo + ' ' + item; }, '');
|
||||
return new hbs.handlebars.SafeString(classString.trim());
|
||||
|
|
|
@ -197,6 +197,14 @@ describe('Core Helpers', function () {
|
|||
|
||||
rendered.string.should.equal('post');
|
||||
});
|
||||
|
||||
it('can render featured class', function () {
|
||||
var post = { featured: true },
|
||||
rendered = handlebars.helpers.post_class.call(post);
|
||||
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('post featured');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ghost_head Helper', function () {
|
||||
|
|
Loading…
Reference in a new issue