Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wildcard redirects #43

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 140 additions & 68 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const redirectVersions = ["main","v0.50","v0.47"]
const redirects = [];
redirectVersions.forEach((version) => {
redirects.push(...generateRedirects(version));
});
// const redirectVersions = ["main","v0.50","v0.47"]
// const redirects = [];
// redirectVersions.forEach((version) => {
// redirects.push(...generateRedirects(version));
// });

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
Expand Down Expand Up @@ -241,7 +241,7 @@ const config = {
{
fromExtensions: ["html"],
toExtensions: ["html"],
redirects: [...redirects,
redirects: [
{
from: ["/master", "/v0.43", "/v0.44"],
to: "/",
Expand Down Expand Up @@ -419,71 +419,143 @@ const config = {
to: "/main/build/modules/",
},
],
createRedirects(existingPath) {
if (existingPath.includes('/develop/advanced')) {
return [
existingPath.replace("/develop/advanced", "/core"),
];
}
if (existingPath.includes('/develop/beginner')) {
return [
existingPath.replace("/develop/beginner", "/basics"),
];
}
if (existingPath.includes('/develop/intro')) {
return [
existingPath.replace("/develop/intro", "/intro"),
];
}
if (existingPath.includes('build/architecture')) {
return [
existingPath.replace("/build/architecture", "/architecture/"),
];
}
if (existingPath.includes('/building-apps')) {
return [
existingPath.replace("/building-apps", "/build/building-apps"),
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
]
}
if (existingPath.includes('/build/building-modules')) {
return [
existingPath.replace("/build/building-modules", "/building-modules"),
]
}
if (existingPath.includes('/build/libraries')) {
return [
existingPath.replace("/build/libraries", "/tooling"),
]
}
if (existingPath.includes('/build/libraries')) {
return [
existingPath.replace("/build/libraries", "/migrations"),
]
}
if (existingPath.includes('/build/modules')) {
return [
existingPath.replace("/build/modules", "/modules"),
]
}
if (existingPath.includes('/build/rfc')) {
return [
existingPath.replace("/build/rfc", "/rfc"),
]
}
if (existingPath.includes('/build/spec')) {
return [
existingPath.replace("/build/spec", "/build/spec"),
]
}
if (existingPath.includes('/build/tooling')) {
return [
existingPath.replace("/build/tooling", "/tooling"),
]
}
if (existingPath.includes('/user/run-node')) {
return [
existingPath.replace("/user/run-node", "/run-node"),
]
}
if (existingPath.includes('/user/validate')) {
return [
existingPath.replace("/user/validate", "/validate"),
];
}
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
},
},
],
],
};
function generateRedirects(version) {
const redirects = [
{
from: `/${version}`,
to: `/`,
},
{
from: `/${version}/core`,
to: `/${version}/develop/advanced/baseapp`,
},
{
from: `/${version}/basics`,
to: `/${version}/develop/beginner/overview-app`,
},
{
from: `/${version}/intro`,
to: `/${version}/develop/intro/what-is-sdk`,
},
{
from: `/${version}/architecture`,
to: `/${version}/build/architecture/`,
},
{
from: `/${version}/building-apps`,
to: `/${version}/build/building-apps/app-go`,
},
{
from: `/${version}/building-modules`,
to: `/${version}/build/building-modules/intro`,
},
{
from: `/${version}/modules`,
to: `/${version}/build/modules`,
},
{
from: `/${version}/packages`,
to: `/${version}/build/packages`,
},
{
from: `/${version}/tooling`,
to: `/${version}/build/tooling`,
},
{
from: `/${version}/migrations`,
to: `/${version}/build/migrations/intro`,
},
{
from: `/${version}/rfc`,
to: `/${version}/build/rfc`,
},
{
from: `/${version}/spec`,
to: `/${version}/build/spec/addresses`,
},
{
from: `/${version}/run-node`,
to: `/${version}/user/run-node/keyring`,
},
];

return redirects;
}
// function generateRedirects(version) {
// const redirects = [
// {
// from: `/${version}`,
// to: `/`,
// },
// {
// from: `/${version}/core`,
// to: `/${version}/develop/advanced/baseapp`,
// },
// {
// from: `/${version}/basics`,
// to: `/${version}/develop/beginner/overview-app`,
// },
// {
// from: `/${version}/intro`,
// to: `/${version}/develop/intro/what-is-sdk`,
// },
// {
// from: `/${version}/architecture`,
// to: `/${version}/build/architecture/`,
// },
// {
// from: `/${version}/building-apps`,
// to: `/${version}/build/building-apps/app-go`,
// },
// {
// from: `/${version}/building-modules`,
// to: `/${version}/build/building-modules/intro`,
// },
// {
// from: `/${version}/modules`,
// to: `/${version}/build/modules`,
// },
// {
// from: `/${version}/packages`,
// to: `/${version}/build/packages`,
// },
// {
// from: `/${version}/tooling`,
// to: `/${version}/build/tooling`,
// },
// {
// from: `/${version}/migrations`,
// to: `/${version}/build/migrations/intro`,
// },
// {
// from: `/${version}/rfc`,
// to: `/${version}/build/rfc`,
// },
// {
// from: `/${version}/spec`,
// to: `/${version}/build/spec/addresses`,
// },
// {
// from: `/${version}/run-node`,
// to: `/${version}/user/run-node/keyring`,
// },
// ];
//
// return redirects;
// }

module.exports = config;