Skip to content

Commit feb32c3

Browse files
authored
docs: add redirects for hotfix release notes URLs (#17630)
1 parent 0696cbd commit feb32c3

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

docs-website/docusaurus.config.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,85 @@ module.exports = {
452452
],
453453
},
454454
],
455+
// Hotfix release notes live as appended sections in the base release page
456+
// (not standalone .md files). We can't use @docusaurus/plugin-client-redirects
457+
// because its PathnameSchema rejects hash fragments in `to`. Instead, write
458+
// meta-refresh stub files directly in postBuild — same mechanism the redirect
459+
// plugin uses internally, but with anchor support.
460+
function hotfixReleaseNoteRedirects() {
461+
const RELEASE_NOTES_BASE = '/docs/managed-datahub/release-notes';
462+
const HOTFIX_REDIRECTS = [
463+
['v_1_0_1', 'v_1_0_0', 'v101'],
464+
['v_1_0_2', 'v_1_0_0', 'v102'],
465+
['v_0_3_17_1', 'v_0_3_17', 'v03171'],
466+
['v_0_3_17_2', 'v_0_3_17', 'v03172'],
467+
['v_0_3_17_3', 'v_0_3_17', 'v03173'],
468+
['v_0_3_17_4', 'v_0_3_17', 'v03174'],
469+
['v_0_3_17_5', 'v_0_3_17', 'v03175'],
470+
['v_0_3_16_1', 'v_0_3_16', 'v03161-acryl'],
471+
['v_0_3_16_2', 'v_0_3_16', 'v03162-acryl'],
472+
['v_0_3_16_3', 'v_0_3_16', 'v03163-acryl'],
473+
['v_0_3_16_4', 'v_0_3_16', 'v03164-acryl'],
474+
['v_0_3_16_5', 'v_0_3_16', 'v03165-acryl'],
475+
['v_0_3_16_6', 'v_0_3_16', 'v03166-acryl'],
476+
['v_0_3_16_7', 'v_0_3_16', 'v03167-acryl'],
477+
['v_0_3_15_4', 'v_0_3_15', 'v03154-acryl'],
478+
['v_0_3_15_5', 'v_0_3_15', 'v03155-acryl'],
479+
['v_0_3_15_6', 'v_0_3_15', 'v03156-acryl'],
480+
['v_0_3_14_1', 'v_0_3_14', 'v03141-acryl'],
481+
['v_0_3_13_1', 'v_0_3_13', 'v03131-acryl'],
482+
['v_0_3_13_2', 'v_0_3_13', 'v03132-acryl'],
483+
['v_0_3_13_3', 'v_0_3_13', 'v03133-acryl'],
484+
['v_0_3_12_1', 'v_0_3_12', 'v03121'],
485+
['v_0_3_12_2', 'v_0_3_12', 'v03122'],
486+
['v_0_3_12_3', 'v_0_3_12', 'v03123'],
487+
['v_0_3_12_4', 'v_0_3_12', 'v03124'],
488+
['v_0_3_11_1', 'v_0_3_11', 'v03111'],
489+
['v_0_3_10_1', 'v_0_3_10', 'v03101'],
490+
['v_0_3_10_2', 'v_0_3_10', 'v03102'],
491+
['v_0_3_10_3', 'v_0_3_10', 'v03103'],
492+
['v_0_3_10_4', 'v_0_3_10', 'v03104'],
493+
['v_0_3_9_2', 'v_0_3_9', 'v0392'],
494+
['v_0_3_8_2', 'v_0_3_8', 'v0382'],
495+
['v_0_3_7_3', 'v_0_3_7', 'v0373'],
496+
['v_0_3_7_4', 'v_0_3_7', 'v0374'],
497+
['v_0_3_7_5', 'v_0_3_7', 'v0375'],
498+
['v_0_3_7_6', 'v_0_3_7', 'v0376'],
499+
['v_0_3_7_7', 'v_0_3_7', 'v0377'],
500+
['v_0_3_7_8', 'v_0_3_7', 'v0378'],
501+
];
502+
return {
503+
name: 'hotfix-release-note-redirects',
504+
async postBuild({ outDir, baseUrl }) {
505+
const fs = require('fs-extra');
506+
const path = require('path');
507+
const joinUrl = (...parts) =>
508+
('/' + parts.join('/')).replace(/\/+/g, '/');
509+
for (const [fromSlug, toSlug, anchor] of HOTFIX_REDIRECTS) {
510+
const fromPath = joinUrl(baseUrl, RELEASE_NOTES_BASE, fromSlug);
511+
const toUrl =
512+
joinUrl(baseUrl, RELEASE_NOTES_BASE, toSlug) + '/#' + anchor;
513+
const filePath = path.join(outDir, fromPath, 'index.html');
514+
const html = `<!DOCTYPE html>
515+
<html lang="en">
516+
<head>
517+
<meta charset="utf-8">
518+
<title>Redirecting…</title>
519+
<link rel="canonical" href="${toUrl}">
520+
<meta name="robots" content="noindex">
521+
<meta http-equiv="refresh" content="0; url=${toUrl}">
522+
</head>
523+
<body>
524+
<p><a href="${toUrl}">Click here if you are not redirected.</a></p>
525+
<script>window.location.replace(${JSON.stringify(toUrl)} + window.location.search);</script>
526+
</body>
527+
</html>
528+
`;
529+
await fs.outputFile(filePath, html);
530+
}
531+
},
532+
};
533+
},
455534
["@docusaurus/plugin-ideal-image", { quality: 100, sizes: [320, 640, 1280, 1440, 1600] }],
456535
"docusaurus-plugin-sass",
457536
[

0 commit comments

Comments
 (0)