mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 00:58:14 -05:00
Merge branch 'add_redirects' of github.com:sclements/scratch-www into s3
# Conflicts: # .eslintrc # server/handler.js
This commit is contained in:
commit
59227e3272
5 changed files with 17 additions and 7 deletions
|
@ -20,8 +20,9 @@
|
|||
"formatMessage": true
|
||||
},
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"blockBindings": true
|
||||
"arrowFunctions": true,
|
||||
"blockBindings": true,
|
||||
"jsx": true
|
||||
},
|
||||
"plugins": [
|
||||
"react"
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
* Constructor
|
||||
*/
|
||||
function Handler (route) {
|
||||
var url = '/' + route.view + '.html';
|
||||
// Handle redirects
|
||||
if (route.redirect) {
|
||||
return (req, res) => { res.redirect(route.redirect); };
|
||||
}
|
||||
|
||||
var url = '/' + route.view + '.html';
|
||||
return function (req, res, next) {
|
||||
req.url = url;
|
||||
next();
|
||||
|
|
|
@ -16,10 +16,9 @@ app.disable('x-powered-by');
|
|||
app.use(log());
|
||||
|
||||
// Bind routes
|
||||
for (var routeId in routes) {
|
||||
var route = routes[routeId];
|
||||
routes.forEach(route => {
|
||||
app.get(route.pattern, handler(route));
|
||||
}
|
||||
});
|
||||
|
||||
app.use(webpackDevMiddleware(compiler));
|
||||
|
||||
|
|
|
@ -43,5 +43,9 @@
|
|||
"pattern": "^/wedo$",
|
||||
"view": "wedo2",
|
||||
"title": "LEGO WeDo 2.0"
|
||||
},
|
||||
{
|
||||
"pattern": "/info/donate/",
|
||||
"redirect": "https://secure.donationpay.org/scratchfoundation/"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -11,7 +11,9 @@ var entry = {
|
|||
init: './src/init.js'
|
||||
};
|
||||
routes.forEach(function (route) {
|
||||
entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
|
||||
if (!route.redirect) {
|
||||
entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
|
||||
}
|
||||
});
|
||||
|
||||
// Config
|
||||
|
|
Loading…
Reference in a new issue