Ghost/core/server/controllers/frontend/channel-config.js
Hannah Wolfe 13c1742eb9 Make frontend routing dynamic & driven by channels
refs #5091

- Move renderChannel to own file
- Update channel config to have get/list methods
- Move main routes to be generated based on the list of channels
- Move RSS routes to be subroutes of channels
- Move redirect301 to be a shared util
- Add full test coverage
- Split frontend route tests into frontend & channels
2016-02-15 15:57:20 +00:00

56 lines
1.4 KiB
JavaScript

var _ = require('lodash'),
config = require('../../config'),
channelConfig;
channelConfig = function channelConfig() {
var defaults = {
index: {
name: 'index',
route: '/',
frontPageTemplate: 'home'
},
tag: {
name: 'tag',
route: '/' + config.routeKeywords.tag + '/:slug/',
postOptions: {
filter: 'tags:\'%s\''
},
data: {
tag: {
type: 'read',
resource: 'tags',
options: {slug: '%s'}
}
},
slugTemplate: true,
editRedirect: '/ghost/settings/tags/:slug/'
},
author: {
name: 'author',
route: '/' + config.routeKeywords.author + '/:slug/',
postOptions: {
filter: 'author:\'%s\''
},
data: {
author: {
type: 'read',
resource: 'users',
options: {slug: '%s'}
}
},
slugTemplate: true,
editRedirect: '/ghost/team/:slug/'
}
};
return defaults;
};
module.exports.list = function list() {
return channelConfig();
};
module.exports.get = function get(name) {
return _.cloneDeep(channelConfig()[name]);
};