mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added meta title and description theme helpers
closes #795 - firstly fixes res.locals to include path again - adds {{media_title}} and {{media_description}} theme helpers
This commit is contained in:
parent
adae9f4180
commit
6a5f88ed18
2 changed files with 35 additions and 0 deletions
|
@ -101,6 +101,7 @@ function ghostLocals(req, res, next) {
|
|||
// Make sure we have a locals value.
|
||||
res.locals = res.locals || {};
|
||||
res.locals.version = packageInfo.version;
|
||||
res.locals.path = req.path;
|
||||
|
||||
if (res.isAdmin) {
|
||||
_.extend(res.locals, {
|
||||
|
|
|
@ -218,6 +218,40 @@ coreHelpers = function (ghost) {
|
|||
});
|
||||
});
|
||||
|
||||
ghost.registerThemeHelper('meta_title', function (options) {
|
||||
var title, blog;
|
||||
blog = ghost.blogGlobals();
|
||||
if (_.isString(this.path)) {
|
||||
if (!this.path || this.path === '/' || this.path === '' || this.path.match(/\/page/)) {
|
||||
blog = ghost.blogGlobals();
|
||||
title = blog.title;
|
||||
} else {
|
||||
title = this.post.title;
|
||||
}
|
||||
}
|
||||
|
||||
return ghost.doFilter('meta_title', title, function (title) {
|
||||
return new hbs.handlebars.SafeString(title.trim());
|
||||
});
|
||||
});
|
||||
|
||||
ghost.registerThemeHelper('meta_description', function (options) {
|
||||
var description, blog;
|
||||
blog = ghost.blogGlobals();
|
||||
if (_.isString(this.path)) {
|
||||
if (!this.path || this.path === '/' || this.path === '' || this.path.match(/\/page/)) {
|
||||
blog = ghost.blogGlobals();
|
||||
description = blog.description;
|
||||
} else {
|
||||
description = '';
|
||||
}
|
||||
}
|
||||
|
||||
return ghost.doFilter('meta_description', description, function (description) {
|
||||
return new hbs.handlebars.SafeString(description.trim());
|
||||
});
|
||||
});
|
||||
|
||||
ghost.registerThemeHelper('ghost_foot', function (options) {
|
||||
var foot = [];
|
||||
foot.push('<script src="/shared/vendor/jquery/jquery.js"></script>');
|
||||
|
|
Loading…
Reference in a new issue