Skip to content

Commit dcd4ace

Browse files
committed
Keep forwarding stubs for retired .mdx mirrors
They have no HTTP rule under the static redirect cap, so the noindex stub still forwards old links. A stub is not a page, so it carries no canonical and the SEO check skips it.
1 parent e875a2f commit dcd4ace

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎scripts/finalize-site.mjs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ for (const file of files) {
6060
let text = await readFile(filename, "utf8");
6161
if (file.endsWith(".html")) {
6262
if (/<meta\s+http-equiv="refresh"/u.test(text)) {
63+
// A retired .mdx mirror has no HTTP rule (the static redirect cap is
64+
// spent on .md), so its stub is the only thing that still forwards it.
65+
if (/\.mdx\/index\.html$/u.test(file)) {
66+
// A forwarding stub is not a page, so it names no canonical.
67+
await writeFile(filename, text.replace(/<link rel="canonical"[^>]*>/u, ""));
68+
continue;
69+
}
6370
await rm(filename);
6471
redirectsRemoved += 1;
6572
continue;

‎scripts/verify-built-seo.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export async function verifyDiscoveryUrls(dist, files, served) {
3838

3939
export async function verifyBuiltSeo(dist = path.resolve("dist")) {
4040
const files = (await readdir(dist, { recursive: true, withFileTypes: true })).filter((entry) => entry.isFile()).map((entry) => path.relative(dist, path.join(entry.parentPath, entry.name)));
41-
const pages = files.filter((file) => file.endsWith("index.html") && !file.startsWith("blume-nav/"));
41+
// Retired .mdx mirrors keep a noindex forwarding stub; they are not pages.
42+
const pages = files.filter((file) => file.endsWith("index.html") && !file.startsWith("blume-nav/") && !/\.mdx\/index\.html$/u.test(file));
4243
const root = "https://spacefast.com/docs/";
4344
const served = new Set(pages.map((file) => `${root}${file.replace(/index\.html$/u, "")}`));
4445
await verifyDiscoveryUrls(dist, files, served);

0 commit comments

Comments
 (0)