improve doc

This commit is contained in:
slorber 2020-06-03 18:13:10 +02:00
parent e057bbd662
commit 812daa8af5

View file

@ -513,7 +513,29 @@ module.exports = {
For custom redirect logic, provide your own `createRedirects` function.
Let's imagine you change the url of an pexisting age, you might want to make sure the old url still works:
Let's imagine you change the url of an existing page, you might want to make sure the old url still works:
```js title="docusaurus.config.js"
module.exports = {
plugins: [
[
'@docusaurus/plugin-client-redirects',
{
redirects: [
{
// : string
to: '/docs/newDocPath',
// : string | string[]
from: ['/docs/oldDocPathFrom2019', '/docs/legacyDocPathFrom2016'],
},
],
},
],
],
};
```
It's possible to use a function to create the redirects for each existing path:
```js title="docusaurus.config.js"
module.exports = {
@ -531,3 +553,30 @@ module.exports = {
],
};
```
Finally, it's possible to use all options at the same time:
```js title="docusaurus.config.js"
module.exports = {
plugins: [
[
'@docusaurus/plugin-client-redirects',
{
fromExtensions: ['html', 'htm'],
toExtensions: ['exe', 'zip'],
redirects: [
{
to: '/docs/newDocPath',
from: '/docs/oldDocPath',
},
],
createRedirects: function (existingPath) {
if (existingPath === '/docs/newDocPath2') {
return ['/docs/oldDocPath2'];
}
},
},
],
],
};
```