From 524174a7c0c4a0a5f9ac5f000b24dc6d5fd3a240 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 29 Nov 2018 10:47:42 +0100 Subject: [PATCH] create redirects for root of sections * ref #32 --- config.js | 16 +++++++++++++++- gatsby-node.js | 18 +++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/config.js b/config.js index 469a07bb..61d93973 100644 --- a/config.js +++ b/config.js @@ -18,5 +18,19 @@ module.exports = { githubContentPath: 'https://github.com/oceanprotocol/docs/blob/master/content', githubDevOceanPath: - 'https://github.com/oceanprotocol/dev-ocean/blob/master/doc' + 'https://github.com/oceanprotocol/dev-ocean/blob/master/doc', + redirects: [ + { + from: '/concepts/', + to: '/concepts/introduction/' + }, + { + from: '/setup/', + to: '/setup/quickstart/' + }, + { + from: '/tutorials/', + to: '/tutorials/introduction/' + } + ] } diff --git a/gatsby-node.js b/gatsby-node.js index f393bf48..a9b002f1 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,5 +1,8 @@ +/* eslint-disable no-console */ + const path = require('path') const { createFilePath } = require('gatsby-source-filesystem') +const { redirects } = require('./config') exports.onCreateNode = ({ node, getNode, actions }) => { const { createNodeField } = actions @@ -34,7 +37,20 @@ exports.onCreateNode = ({ node, getNode, actions }) => { } exports.createPages = ({ graphql, actions }) => { - const { createPage } = actions + const { createPage, createRedirect } = actions + + // + // create redirects + // + redirects.forEach(({ from, to }) => { + createRedirect({ + fromPath: from, + redirectInBrowser: true, + toPath: to + }) + + console.log('Create redirect: ' + from + ' --> ' + to) + }) return new Promise((resolve, reject) => { resolve(