diff --git a/.eslintrc b/.eslintrc index d8d50bcb8..ca3e7f389 100644 --- a/.eslintrc +++ b/.eslintrc @@ -20,8 +20,9 @@ "formatMessage": true }, "ecmaFeatures": { - "jsx": true, - "blockBindings": true + "arrowFunctions": true, + "blockBindings": true, + "jsx": true }, "plugins": [ "react" diff --git a/server/handler.js b/server/handler.js index 7e64d3fbf..b21c51288 100644 --- a/server/handler.js +++ b/server/handler.js @@ -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(); diff --git a/server/index.js b/server/index.js index 4db8d4801..e9b38dbcb 100644 --- a/server/index.js +++ b/server/index.js @@ -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)); diff --git a/src/routes.json b/src/routes.json index c1cc9a1bc..371d67fcf 100644 --- a/src/routes.json +++ b/src/routes.json @@ -43,5 +43,9 @@ "pattern": "^/wedo$", "view": "wedo2", "title": "LEGO WeDo 2.0" + }, + { + "pattern": "/info/donate/", + "redirect": "https://secure.donationpay.org/scratchfoundation/" } ] diff --git a/webpack.config.js b/webpack.config.js index 32e4ea27d..a024a9dd4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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