mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
a927aecc3f
closes #10389
34 lines
826 B
JavaScript
34 lines
826 B
JavaScript
const ParentRouter = require('./ParentRouter');
|
|
const urlService = require('../url');
|
|
const controllers = require('./controllers');
|
|
|
|
class PreviewRouter extends ParentRouter {
|
|
constructor(RESOURCE_CONFIG) {
|
|
super('PreviewRouter');
|
|
|
|
this.RESOURCE_CONFIG = RESOURCE_CONFIG.QUERY.preview;
|
|
|
|
this.route = {value: '/p/'};
|
|
|
|
this._registerRoutes();
|
|
}
|
|
|
|
_registerRoutes() {
|
|
this.router().use(this._prepareContext.bind(this));
|
|
|
|
this.mountRoute(urlService.utils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.preview);
|
|
}
|
|
|
|
_prepareContext(req, res, next) {
|
|
res.routerOptions = {
|
|
type: 'entry',
|
|
query: this.RESOURCE_CONFIG,
|
|
context: ['preview']
|
|
};
|
|
|
|
next();
|
|
}
|
|
}
|
|
|
|
module.exports = PreviewRouter;
|