|
| 1 | +const { entries } = require('./gitbook-redirects.json'); |
| 2 | + |
| 3 | +export default ({ router }) => { |
| 4 | + router.addRoutes([ |
| 5 | + // Redirect the old, extra /apostrophe/ path. |
| 6 | + { |
| 7 | + path: '/apostrophe/*', |
| 8 | + redirect: '/*' |
| 9 | + }, |
| 10 | + // Redirect the deprecated /tutorials subdirectory |
| 11 | + { |
| 12 | + path: '/tutorials/*', |
| 13 | + redirect: to => { |
| 14 | + if (to.params && to.params.pathMatch) { |
| 15 | + const leadRegex = /^tutorials/; |
| 16 | + return to.params.pathMatch.replace(leadRegex, ''); |
| 17 | + } |
| 18 | + return '/'; |
| 19 | + } |
| 20 | + }, |
| 21 | + // Redirect the funky old devops path. |
| 22 | + { |
| 23 | + path: '/apostrophe-devops/devops/', |
| 24 | + redirect: '/devops/' |
| 25 | + }, |
| 26 | + { |
| 27 | + path: '/apostrophe-devops/devops/*', |
| 28 | + redirect: '/devops/*' |
| 29 | + }, |
| 30 | + // Not sure how this one is coming up often. |
| 31 | + { |
| 32 | + path: '/devops/apostrophe-devops/devops/*', |
| 33 | + redirect: '/devops/*' |
| 34 | + }, |
| 35 | + // Redirect the funky old howtos path. |
| 36 | + { |
| 37 | + path: '/howtos/howtos/', |
| 38 | + redirect: '/howtos/' |
| 39 | + }, |
| 40 | + { |
| 41 | + path: '/howtos/howtos/*', |
| 42 | + redirect: '/howtos/*' |
| 43 | + }, |
| 44 | + // There were duplicate devops/howtos pages. Redirect the deprecated ones. |
| 45 | + { |
| 46 | + path: '/devops/windows', |
| 47 | + redirect: '/howtos/windows' |
| 48 | + }, |
| 49 | + { |
| 50 | + path: '/devops/docker', |
| 51 | + redirect: '/howtos/docker' |
| 52 | + }, |
| 53 | + { |
| 54 | + path: '/devops/migration', |
| 55 | + redirect: '/howtos/migration' |
| 56 | + }, |
| 57 | + { |
| 58 | + path: '/devops/storing-sessions-in-redis', |
| 59 | + redirect: '/howtos/storing-sessions-in-redis' |
| 60 | + }, |
| 61 | + { |
| 62 | + path: '/howtos/email', |
| 63 | + redirect: '/devops/email' |
| 64 | + }, |
| 65 | + { |
| 66 | + path: '/howtos/multicore', |
| 67 | + redirect: '/devops/multicore' |
| 68 | + }, |
| 69 | + // Redirect deployment and cloud, which used to be in howtos |
| 70 | + { |
| 71 | + path: '/howtos/deployment/', |
| 72 | + redirect: '/devops/deployment/' |
| 73 | + }, |
| 74 | + { |
| 75 | + path: '/howtos/deployment/*', |
| 76 | + redirect: to => { |
| 77 | + if (to.params && to.params.pathMatch) { |
| 78 | + const leadRegex = /^howtos\/deployment/; |
| 79 | + return to.params.pathMatch.replace(leadRegex, 'devops/deployment'); |
| 80 | + } |
| 81 | + return '/devops/deployment'; |
| 82 | + } |
| 83 | + }, |
| 84 | + { |
| 85 | + path: '/howtos/cloud/', |
| 86 | + redirect: '/devops/cloud/' |
| 87 | + }, |
| 88 | + { |
| 89 | + path: '/howtos/cloud/*', |
| 90 | + redirect: to => { |
| 91 | + if (to.params && to.params.pathMatch) { |
| 92 | + const leadRegex = /^howtos\/cloud/; |
| 93 | + return to.params.pathMatch.replace(leadRegex, 'devops/cloud'); |
| 94 | + } |
| 95 | + return '/devops/cloud'; |
| 96 | + } |
| 97 | + }, |
| 98 | + { |
| 99 | + path: '/other/glossary', |
| 100 | + redirect: '/reference/glossary' |
| 101 | + }, |
| 102 | + { |
| 103 | + path: '/other/core-server', |
| 104 | + redirect: '/reference/core-server' |
| 105 | + }, |
| 106 | + { |
| 107 | + path: '/other/core-browser', |
| 108 | + redirect: '/reference/core-browser' |
| 109 | + } |
| 110 | + ].concat(entries)); |
| 111 | +}; |
0 commit comments