0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added no-image class to content w/o feature_image

no issue

- Most of the offical Ghost themes have been doing this manually
- So we'll just do it by default:
This commit is contained in:
Hannah Wolfe 2019-11-05 18:02:21 +07:00
parent 72679aefb9
commit 1cdc181c54
2 changed files with 31 additions and 1 deletions

View file

@ -11,8 +11,11 @@ module.exports = function post_class() { // eslint-disable-line camelcase
var classes = ['post'],
tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
featured = this.post && this.post.featured ? this.post.featured : this.featured || false,
image = this.post && this.post.feature_image ? this.post.feature_image : this.feature_image || false,
page = this.post && this.post.page ? this.post.page : this.page || false;
console.log(this);
if (tags) {
classes = classes.concat(tags.map(function (tag) {
return 'tag-' + tag.slug;
@ -23,6 +26,10 @@ module.exports = function post_class() { // eslint-disable-line camelcase
classes.push('featured');
}
if (!image) {
classes.push('no-image');
}
if (page) {
classes.push('page');
}

View file

@ -7,6 +7,13 @@ describe('{{post_class}} helper', function () {
it('can render class string', function () {
var rendered = helpers.post_class.call({});
should.exist(rendered);
rendered.string.should.equal('post no-image');
});
it('can render class string without no-image class', function () {
var rendered = helpers.post_class.call({feature_image: 'blah'});
should.exist(rendered);
rendered.string.should.equal('post');
});
@ -16,13 +23,29 @@ describe('{{post_class}} helper', function () {
rendered = helpers.post_class.call(post);
should.exist(rendered);
rendered.string.should.equal('post featured');
rendered.string.should.equal('post featured no-image');
});
it('can render featured class without no-image class', function () {
var post = {featured: true, feature_image: 'asdass'},
rendered = helpers.post_class.call(post);
should.exist(rendered);
rendered.string.should.equal('post featured no-image');
});
it('can render page class', function () {
var post = {page: true},
rendered = helpers.post_class.call(post);
should.exist(rendered);
rendered.string.should.equal('post no-image page');
});
it('can render page class without no-image class', function () {
var post = {page: true, featured_image: 'asdasdas'},
rendered = helpers.post_class.call(post);
should.exist(rendered);
rendered.string.should.equal('post page');
});