diff --git a/core/server.js b/core/server.js index 94fddce818..ed3af44370 100644 --- a/core/server.js +++ b/core/server.js @@ -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, { diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index cbe6dbe92b..df3b9144e5 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -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('');