2018-09-20 23:34:34 +05:30
|
|
|
const ghostVersion = require('../../../lib/ghost-version');
|
2021-04-26 14:38:57 +01:00
|
|
|
const bridge = require('../../../../bridge');
|
2016-10-10 20:14:32 +01:00
|
|
|
|
|
|
|
// ### 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;
|
2018-10-17 09:23:57 +02:00
|
|
|
// make ghost api version available for the theme + routing
|
2021-04-23 14:19:18 +01:00
|
|
|
res.locals.apiVersion = bridge.getFrontendApiVersion();
|
2016-10-10 20:14:32 +01:00
|
|
|
|
|
|
|
next();
|
|
|
|
};
|