mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
🔥 Remove the deprecated body classes (#7510)
closes #2597 - Remove .archive-template - Remove .page - Don't output .post-template on pages - Use `page-slug` instead of `page-template-slug` - Always output `page-slug` irrelevant of whether or not there is a custom template
This commit is contained in:
parent
613015c792
commit
01f5dc238f
@ -8,8 +8,6 @@
|
||||
|
||||
var hbs = require('express-hbs'),
|
||||
_ = require('lodash'),
|
||||
// @TODO Fix this
|
||||
template = require('../controllers/frontend/templates'),
|
||||
body_class;
|
||||
|
||||
body_class = function (options) {
|
||||
@ -17,22 +15,15 @@ body_class = function (options) {
|
||||
context = options.data.root.context,
|
||||
post = this.post,
|
||||
tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
|
||||
page = this.post && this.post.page ? this.post.page : this.page || false,
|
||||
activeTheme = options.data.root.settings.activeTheme,
|
||||
view;
|
||||
|
||||
if (post) {
|
||||
// To be removed from pages by #2597 when we're ready to deprecate this
|
||||
// i.e. this should be if (_.includes(context, 'post') && post) { ... }
|
||||
classes.push('post-template');
|
||||
}
|
||||
page = this.post && this.post.page ? this.post.page : this.page || false;
|
||||
|
||||
if (_.includes(context, 'home')) {
|
||||
classes.push('home-template');
|
||||
} else if (_.includes(context, 'post') && post) {
|
||||
classes.push('post-template');
|
||||
} else if (_.includes(context, 'page') && page) {
|
||||
classes.push('page-template');
|
||||
// To be removed by #2597 when we're ready to deprecate this
|
||||
classes.push('page');
|
||||
classes.push('page-' + this.post.slug);
|
||||
} else if (_.includes(context, 'tag') && this.tag) {
|
||||
classes.push('tag-template');
|
||||
classes.push('tag-' + this.tag.slug);
|
||||
@ -49,19 +40,6 @@ body_class = function (options) {
|
||||
|
||||
if (_.includes(context, 'paged')) {
|
||||
classes.push('paged');
|
||||
// To be removed from pages by #2597 when we're ready to deprecate this
|
||||
classes.push('archive-template');
|
||||
}
|
||||
|
||||
if (post && page) {
|
||||
view = template.single(activeTheme, post).split('-');
|
||||
|
||||
if (view[0] === 'page' && view.length > 1) {
|
||||
classes.push(view.join('-'));
|
||||
// To be removed by #2597 when we're ready to deprecate this
|
||||
view.splice(1, 0, 'template');
|
||||
classes.push(view.join('-'));
|
||||
}
|
||||
}
|
||||
|
||||
classes = _.reduce(classes, function (memo, item) { return memo + ' ' + item; }, '');
|
||||
|
@ -86,7 +86,7 @@ describe('{{body_class}} helper', function () {
|
||||
{relativeUrl: '/page/4'}
|
||||
);
|
||||
|
||||
rendered.string.should.equal('paged archive-template');
|
||||
rendered.string.should.equal('paged');
|
||||
});
|
||||
|
||||
it('tag page', function () {
|
||||
@ -104,7 +104,7 @@ describe('{{body_class}} helper', function () {
|
||||
{relativeUrl: '/tag/foo/page/2', tag: {slug: 'foo'}}
|
||||
);
|
||||
|
||||
rendered.string.should.equal('tag-template tag-foo paged archive-template');
|
||||
rendered.string.should.equal('tag-template tag-foo paged');
|
||||
});
|
||||
|
||||
it('author page', function () {
|
||||
@ -122,7 +122,7 @@ describe('{{body_class}} helper', function () {
|
||||
{relativeUrl: '/author/bar/page/2', author: {slug: 'bar'}}
|
||||
);
|
||||
|
||||
rendered.string.should.equal('author-template author-bar paged archive-template');
|
||||
rendered.string.should.equal('author-template author-bar paged');
|
||||
});
|
||||
|
||||
it('private route for password protection', function () {
|
||||
@ -146,19 +146,19 @@ describe('{{body_class}} helper', function () {
|
||||
it('a static page', function () {
|
||||
var rendered = callBodyClassWithContext(
|
||||
['page'],
|
||||
{relativeUrl: '/about', post: {page: true}}
|
||||
{relativeUrl: '/about', post: {page: true, slug: 'about'}}
|
||||
);
|
||||
|
||||
rendered.string.should.equal('post-template page-template page');
|
||||
rendered.string.should.equal('page-template page-about');
|
||||
});
|
||||
|
||||
it('a static page with custom template', function () {
|
||||
it('a static page with custom template (is now the same as one without)', function () {
|
||||
var rendered = callBodyClassWithContext(
|
||||
['page'],
|
||||
{relativeUrl: '/about', post: {page: true, slug: 'about'}}
|
||||
);
|
||||
|
||||
rendered.string.should.equal('post-template page-template page page-about page-template-about');
|
||||
rendered.string.should.equal('page-template page-about');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user