mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
df7e64fafa
refs #10790 - Moved /core/apps into core/frontend - Moved /core/server/helpers to /core/frontend/helpers along with /core/server/services/themes - Changed helper location in overrides - Moved /core/server/services/routing to /core/frontend/services - Moved /core/server/services/url to /core/frontend/services - Moved /core/server/data/meta to /core/frontend/meta - Moved /core/server/services/rss to /core/frontend/services - Moved /core/server/data/xml to /core/frontend/services
35 lines
1011 B
JavaScript
35 lines
1011 B
JavaScript
// # Post Class Helper
|
|
// Usage: `{{post_class}}`
|
|
//
|
|
// Output classes for the body element
|
|
var proxy = require('./proxy'),
|
|
_ = require('lodash'),
|
|
SafeString = proxy.SafeString;
|
|
|
|
// We use the name post_class to match the helper for consistency:
|
|
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,
|
|
page = this.post && this.post.page ? this.post.page : this.page || false;
|
|
|
|
if (tags) {
|
|
classes = classes.concat(tags.map(function (tag) {
|
|
return 'tag-' + tag.slug;
|
|
}));
|
|
}
|
|
|
|
if (featured) {
|
|
classes.push('featured');
|
|
}
|
|
|
|
if (page) {
|
|
classes.push('page');
|
|
}
|
|
|
|
classes = _.reduce(classes, function (memo, item) {
|
|
return memo + ' ' + item;
|
|
}, '');
|
|
return new SafeString(classes.trim());
|
|
};
|