mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
987e41e8d6
refs #9866 - each request get's the ghost api version attached - this makes it possible to access the version in all steps (routing, theme helpers)
19 lines
765 B
JavaScript
19 lines
765 B
JavaScript
const ghostVersion = require('../../../lib/ghost-version');
|
|
const themeService = require('../../../services/themes');
|
|
|
|
// ### GhostLocals Middleware
|
|
// Expose the standard locals that every request will need to have available
|
|
module.exports = function ghostLocals(req, res, next) {
|
|
// Make sure we have a locals value.
|
|
res.locals = res.locals || {};
|
|
// The current Ghost version
|
|
res.locals.version = ghostVersion.full;
|
|
// The current Ghost version, but only major.minor
|
|
res.locals.safeVersion = ghostVersion.safe;
|
|
// relative path from the URL
|
|
res.locals.relativeUrl = req.path;
|
|
// make ghost api version available for the theme + routing
|
|
res.locals.apiVersion = themeService.getActive().engine('ghost-api');
|
|
|
|
next();
|
|
};
|