mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-10 17:53:36 +02:00
docs: don't rewrite absolute doc links
This commit is contained in:
parent
be9cad8a61
commit
3fce0c4090
@ -59,14 +59,17 @@ const documentUrls = Object.entries(SDKS).map(
|
|||||||
|
|
||||||
// Replace links in the incoming readme content.
|
// Replace links in the incoming readme content.
|
||||||
//
|
//
|
||||||
// There's two cases we want to handle:
|
// There's one cases we want to handle:
|
||||||
//
|
//
|
||||||
// 1. Relative links that point to the repo. These must be prefixed with the
|
// 1. Relative links that point to the repo. These must be prefixed with the
|
||||||
// link to the github repo.
|
// link to the github repo.
|
||||||
//
|
//
|
||||||
// 2. Absolute links to docs.getunleash.io. While absolute links will work, they
|
// Note: You might be tempted to handle absolute links to docs.getunleash.io and
|
||||||
// trigger full page refreshes. If we can make them relative links instead, then
|
// make them relative. While absolute links will work, they trigger full page
|
||||||
// we'll get a slightly smoother user experience.
|
// refreshes. Relative links give a slightly smoother user experience.
|
||||||
|
//
|
||||||
|
// However, if the old link goes to a redirect, then the client-side redirect
|
||||||
|
// will not kick in, so you'll end up with a "Page not found".
|
||||||
const replaceLinks = ({ content, repo }) => {
|
const replaceLinks = ({ content, repo }) => {
|
||||||
const markdownLink = /(?<=\[.*\]\(\s?)(\S+)(?=.*\))/g;
|
const markdownLink = /(?<=\[.*\]\(\s?)(\S+)(?=.*\))/g;
|
||||||
|
|
||||||
@ -76,13 +79,6 @@ const replaceLinks = ({ content, repo }) => {
|
|||||||
// https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
|
// https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
|
||||||
const parsedUrl = new URL(url);
|
const parsedUrl = new URL(url);
|
||||||
|
|
||||||
// case 2:
|
|
||||||
if (parsedUrl.hostname === 'docs.getunleash.io') {
|
|
||||||
return `${parsedUrl.pathname ?? '/'}${parsedUrl.query ?? ''}${
|
|
||||||
parsedUrl.hash ?? ''
|
|
||||||
}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
} catch {
|
} catch {
|
||||||
// case 1
|
// case 1
|
||||||
|
Loading…
Reference in New Issue
Block a user