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:
Mark Berger 2013-12-27 18:21:43 -05:00
parent 32f65759f7
commit 075dd8ac9b
3 changed files with 20 additions and 3 deletions

View File

@ -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,

View File

@ -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)]();

View File

@ -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);
}
});
};