2022-09-07 10:36:15 +08:00
|
|
|
const path = require('path');
|
|
|
|
|
2022-09-16 14:45:22 +08:00
|
|
|
module.exports = function (config) {
|
2022-02-22 18:35:06 +08:00
|
|
|
return {
|
|
|
|
name: 'docusaurus-redirect-plugin',
|
2022-09-07 14:49:54 +08:00
|
|
|
async contentLoaded({ actions }) {
|
2022-02-23 11:24:50 +08:00
|
|
|
const { createData, addRoute } = actions;
|
2022-02-22 18:35:06 +08:00
|
|
|
|
|
|
|
const routes = [
|
2022-07-01 16:47:25 +08:00
|
|
|
// {
|
|
|
|
// from: '/docs/guide/advance/fusion',
|
|
|
|
// to: '/docs/plugin/list/fusion',
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// from: '/docs/guide/advance/antd',
|
|
|
|
// to: '/docs/plugin/list/antd',
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// from: '/docs/guide/develop/plugin-dev',
|
|
|
|
// to: '/docs/plugin/develop/start',
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// from: '/docs/guide/develop/plugin-build',
|
|
|
|
// to: '/docs/plugin/develop/build',
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// from: '/docs/guide/develop/plugin-runtime',
|
|
|
|
// to: '/docs/plugin/develop/runtime',
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// from: '/docs/guide/develop/plugin-list',
|
|
|
|
// to: '/docs/plugin/list/moment-locales',
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// from: '/docs/guide/basic/api',
|
|
|
|
// to: '/docs/config/about',
|
|
|
|
// },
|
2022-02-22 18:35:06 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
const redirectConfigPath = await createData(
|
|
|
|
'redirectConfig.json',
|
|
|
|
JSON.stringify(routes),
|
|
|
|
);
|
|
|
|
|
|
|
|
routes.forEach((item) => {
|
|
|
|
addRoute({
|
|
|
|
path: item.from,
|
|
|
|
component: '@site/src/components/Redirect',
|
|
|
|
modules: {
|
|
|
|
// propName -> JSON file path
|
|
|
|
redirectConfig: redirectConfigPath,
|
|
|
|
},
|
|
|
|
exact: true,
|
|
|
|
});
|
|
|
|
});
|
2022-02-23 11:24:50 +08:00
|
|
|
|
2022-02-22 18:35:06 +08:00
|
|
|
addRoute({
|
2022-09-07 10:36:15 +08:00
|
|
|
path: path.join(config.baseUrl, '/component'),
|
2022-02-22 18:35:06 +08:00
|
|
|
component: '@site/src/components/Redirect',
|
|
|
|
modules: {
|
|
|
|
// propName -> JSON file path
|
|
|
|
redirectConfig: redirectConfigPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
addRoute({
|
2022-09-07 10:36:15 +08:00
|
|
|
path: path.join(config.baseUrl, '/docs/guide/advance'),
|
2022-02-22 18:35:06 +08:00
|
|
|
component: '@site/src/components/Redirect',
|
|
|
|
modules: {
|
|
|
|
// propName -> JSON file path
|
|
|
|
redirectConfig: redirectConfigPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
addRoute({
|
2022-09-07 10:36:15 +08:00
|
|
|
path: path.join(config.baseUrl, '/docs/materials'),
|
2022-02-22 18:35:06 +08:00
|
|
|
component: '@site/src/components/Redirect',
|
|
|
|
modules: {
|
|
|
|
// propName -> JSON file path
|
|
|
|
redirectConfig: redirectConfigPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
addRoute({
|
2022-09-07 10:36:15 +08:00
|
|
|
path: path.join(config.baseUrl, '/docs/icestark'),
|
2022-02-22 18:35:06 +08:00
|
|
|
component: '@site/src/components/Redirect',
|
|
|
|
modules: {
|
|
|
|
// propName -> JSON file path
|
|
|
|
redirectConfig: redirectConfigPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
2022-09-16 14:45:22 +08:00
|
|
|
};
|