mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
Static pages do not use dated permalinks
closes #1753 - Pages are registered to '/:slug/' route if posts are using dated permalinks
This commit is contained in:
parent
32f65759f7
commit
075dd8ac9b
@ -68,7 +68,7 @@ frontendControllers = {
|
||||
});
|
||||
},
|
||||
'single': function (req, res, next) {
|
||||
api.posts.read(_.pick(req.params, ['id', 'slug'])).then(function (post) {
|
||||
api.posts.read(_.pick(req.params, ['id', 'slug', 'page'])).then(function (post) {
|
||||
if (post) {
|
||||
filters.doFilter('prePostsRender', post).then(function (post) {
|
||||
api.settings.read('activeTheme').then(function (activeTheme) {
|
||||
@ -90,6 +90,14 @@ frontendControllers = {
|
||||
return next(e);
|
||||
});
|
||||
},
|
||||
'post': function (req, res, next) {
|
||||
req.params.page = 0;
|
||||
return frontendControllers.single(req, res, next);
|
||||
},
|
||||
'page': function (req, res, next) {
|
||||
req.params.page = 1;
|
||||
return frontendControllers.single(req, res, next);
|
||||
},
|
||||
'rss': function (req, res, next) {
|
||||
// Initialize RSS
|
||||
var siteUrl = config().url,
|
||||
|
@ -110,7 +110,11 @@ coreHelpers.url = function (options) {
|
||||
output += path;
|
||||
}
|
||||
if (models.isPost(self)) {
|
||||
output += permalinks.value;
|
||||
if (self.page === 1) {
|
||||
output += '/:slug/';
|
||||
} else {
|
||||
output += permalinks.value;
|
||||
}
|
||||
output = output.replace(/(:[a-z]+)/g, function (match) {
|
||||
if (_.has(tags, match.substr(1))) {
|
||||
return tags[match.substr(1)]();
|
||||
|
@ -9,6 +9,11 @@ module.exports = function (server) {
|
||||
server.get('/', frontend.homepage);
|
||||
|
||||
api.settings.read('permalinks').then(function (permalinks) {
|
||||
server.get(permalinks.value, frontend.single);
|
||||
if (permalinks.value !== '/:slug/') {
|
||||
server.get('/:slug/', frontend.page);
|
||||
server.get(permalinks.value, frontend.post);
|
||||
} else {
|
||||
server.get(permalinks.value, frontend.single);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user