mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #1772 from markberger/1753-static-page-url
Static pages do not use dated permalinks
This commit is contained in:
commit
6f7f61d112
3 changed files with 20 additions and 3 deletions
|
@ -68,7 +68,7 @@ frontendControllers = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'single': function (req, res, next) {
|
'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) {
|
if (post) {
|
||||||
filters.doFilter('prePostsRender', post).then(function (post) {
|
filters.doFilter('prePostsRender', post).then(function (post) {
|
||||||
api.settings.read('activeTheme').then(function (activeTheme) {
|
api.settings.read('activeTheme').then(function (activeTheme) {
|
||||||
|
@ -90,6 +90,14 @@ frontendControllers = {
|
||||||
return next(e);
|
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) {
|
'rss': function (req, res, next) {
|
||||||
// Initialize RSS
|
// Initialize RSS
|
||||||
var siteUrl = config().url,
|
var siteUrl = config().url,
|
||||||
|
|
|
@ -108,7 +108,11 @@ coreHelpers.url = function (options) {
|
||||||
output += config.paths().subdir;
|
output += config.paths().subdir;
|
||||||
}
|
}
|
||||||
if (models.isPost(self)) {
|
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) {
|
output = output.replace(/(:[a-z]+)/g, function (match) {
|
||||||
if (_.has(tags, match.substr(1))) {
|
if (_.has(tags, match.substr(1))) {
|
||||||
return tags[match.substr(1)]();
|
return tags[match.substr(1)]();
|
||||||
|
|
|
@ -9,6 +9,11 @@ module.exports = function (server) {
|
||||||
server.get('/', frontend.homepage);
|
server.get('/', frontend.homepage);
|
||||||
|
|
||||||
api.settings.read('permalinks').then(function (permalinks) {
|
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…
Add table
Reference in a new issue