mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
23f59c341c
no issue - removed the `routeKeywords` property from the config and used hard coded keywords. - removed `routeKeywords` from public configuration API endpoint, as it's no longer used in the Admin.
28 lines
767 B
JavaScript
28 lines
767 B
JavaScript
var router = require('./lib/router'),
|
|
registerHelpers = require('./lib/helpers'),
|
|
urlService = require('../../services/url'),
|
|
|
|
// Dirty requires
|
|
settingsCache = require('../../services/settings/cache');
|
|
|
|
function ampRouter(req, res) {
|
|
if (settingsCache.get('amp') === true) {
|
|
return router.apply(this, arguments);
|
|
} else {
|
|
// routeKeywords.amp: 'amp'
|
|
var redirectUrl = req.originalUrl.replace(/amp\/$/, '');
|
|
urlService.utils.redirect301(res, redirectUrl);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
activate: function activate(ghost) {
|
|
// routeKeywords.amp: 'amp'
|
|
var ampRoute = '*/amp/';
|
|
|
|
ghost.routeService.registerRouter(ampRoute, ampRouter);
|
|
|
|
registerHelpers(ghost);
|
|
}
|
|
};
|