Skip to main content
Version: 2.0.0-beta.0

๐Ÿ“ฆ plugin-client-redirects

ํด๋ผ์ด์–ธํŠธ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๋„ํ์‚ฌ์šฐ๋ฃจ์Šค ํ”Œ๋Ÿฌ๊ทธ์ธ์ž…๋‹ˆ๋‹ค.

ํ”Œ๋Ÿฌ๊ทธ์ธ์—์„œ๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ๋งŒ๋“  ๋„ํ์‚ฌ์šฐ๋ฃจ์Šค ํŽ˜์ด์ง€๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•  ์ˆ˜ ์žˆ๋„๋ก ์—ฌ๋Ÿฌ๋ถ„์˜ ์ •์ ์ธ ์‚ฌ์ดํŠธ์— HTML ํŽ˜์ด์ง€๋ฅผ ์ถ”๊ฐ€๋กœ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

note

์ด ํ”Œ๋Ÿฌ๊ทธ์ธ์€ ์ œํ’ˆ ๋นŒ๋“œ ์‹œ์—๋งŒ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ๊ธฐ๋Šฅ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

caution

๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด ์„œ๋ฒ„ ์ธก ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ์—ฌ๋Ÿฌ๋ถ„์˜ ํ˜ธ์ŠคํŠธ ์„œ๋น„์Šค ์—…์ฒด๊ฒŒ ์ด ๊ธฐ๋Šฅ์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š”์ง€ ๋จผ์ € ํ™•์ธํ•ด๋ณด์„ธ์š”.

์„ค์น˜#

npm install --save @docusaurus/plugin-client-redirects

์„ค์ •#

์ฃผ๋กœ ์—ฌ๋Ÿฌ๋ถ„์ด /myDocusaurusPage๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์„ ๋•Œ /myDocusaurusPage.html์—์„œ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-client-redirects',
{
fromExtensions: ['html'],
},
],
],
};

๋‘ ๋ฒˆ์งธ๋Š” /myDocusaurusPage.html๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์„ ๋•Œ /myDocusaurusPage์—์„œ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-client-redirects',
{
toExtensions: ['html'],
},
],
],
};

createRedirects ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด ์‚ฌ์šฉ์ž ์ง€์ • ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ๋กœ์ง์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŽ˜์ด์ง€์˜ url์„ ๋ณ€๊ฒฝํ•˜์ง€๋งŒ ์ด์ „ url๋„ ๋™์ž‘ํ•˜๊ธฐ๋ฅผ ์›ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-client-redirects',
{
redirects: [
{
to: '/docs/newDocPath', // string
from: ['/docs/oldDocPathFrom2019', '/docs/legacyDocPathFrom2016'], // string | string[]
},
],
},
],
],
};

๊ฐ ๊ฒฝ๋กœ์— ๋Œ€ํ•œ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ๋ฅผ ์„ค์ •ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด ๊ธฐ๋Šฅ์„ ์ง€์›ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-client-redirects',
{
createRedirects: function (existingPath) {
if (existingPath === '/docs/newDocPath') {
return ['/docs/oldDocPathFrom2019', '/docs/legacyDocPathFrom2016']; // string | string[]
}
},
},
],
],
};

๋งˆ์ง€๋ง‰์œผ๋กœ ๋ชจ๋“  ์˜ต์…˜์„ ํ•œ ๋ฒˆ์— ์ ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

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'];
}
},
},
],
],
};