Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[build]
command = "npm run build"
publish = "dist"

[build.environment]
NODE_OPTIONS = "--max-old-space-size=4096"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"scripts": {
"dev": "astro dev",
"build": "astro build",
"build": "NODE_OPTIONS=--max-old-space-size=4096 astro build",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work on Windows.

"preview": "astro preview",
"astro": "astro",
"lint": "eslint .",
Expand Down
67 changes: 31 additions & 36 deletions src/config/redirect.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,64 @@
// Redirect .html and non-.html blog post URLs to the new format. This will ensure that any existing links to blog posts will continue to work and redirect users to the correct location on the new site.
// Legacy/external URL remaps that can't be derived from the content collections:
// old blog permalinks, links to the archived v2 docs, and the changelog page
// that now lives on GitHub.
//
// Everything else is handled elsewhere, so it's intentionally absent here:
// - The systematic "non-localized path → /en/…" redirects (guides, resources,
// api, blog posts) are generated from the content collections by
// `src/pages/[...path].astro`.
// - Stripping the `.html` extension is handled by Cloudflare, so paths are
// written without it (e.g. `/2x/guide`, not `/2x/guide.html`).

const blog = {
'/2024/07/16/welcome-post.html': '/en/blog/2024-07-16-welcome-post',
'/blog/posts': '/en/blog',
'/2024/07/16/welcome-post': '/en/blog/2024-07-16-welcome-post',
'/2024/09/29/security-releases.html': '/en/blog/2024-09-29-security-releases',
'/2024/09/29/security-releases': '/en/blog/2024-09-29-security-releases',
'/2024/10/01/HeroDevs-partnership-announcement.html':
'/en/blog/2024-10-01-herodevs-partnership-announcement',
'/2024/10/01/HeroDevs-partnership-announcement':
'/en/blog/2024-10-01-herodevs-partnership-announcement',
'/2024/10/15/v5-release': '/en/blog/2024-10-15-v5-release',
'/2024/10/15/v5-release.html': '/en/blog/2024-10-15-v5-release',
'/2024/10/22/security-audit-milestone-achievement.html':
'/en/blog/2024-10-22-security-audit-milestone-achievement',
'/2024/10/22/security-audit-milestone-achievement':
'/en/blog/2024-10-22-security-audit-milestone-achievement',
'/2025/01/09/rewind-2024-triumphs-and-2025-vision.html':
'/en/blog/2025-01-09-rewind-2024-triumphs-and-2025-vision',
'/2025/01/09/rewind-2024-triumphs-and-2025-vision':
'/en/blog/2025-01-09-rewind-2024-triumphs-and-2025-vision',
'/2025/03/31/v5-1-latest-release.html': '/en/blog/2025-03-31-v5-1-latest-release',
'/2025/03/31/v5-1-latest-release': '/en/blog/2025-03-31-v5-1-latest-release',
'/2025/05/16/express-cleanup-legacy-packages.html':
'/en/blog/2025-05-16-express-cleanup-legacy-packages',
'/2025/05/16/express-cleanup-legacy-packages':
'/en/blog/2025-05-16-express-cleanup-legacy-packages',
'/2025/05/19/security-releases.html': '/en/blog/2025-05-19-security-releases',
'/2025/05/19/security-releases': '/en/blog/2025-05-19-security-releases',
'/2025/06/05/vulnerability-reporting-process-overhaul.html':
'/en/blog/2025-06-05-vulnerability-reporting-process-overhaul',
'/2025/06/05/vulnerability-reporting-process-overhaul':
'/en/blog/2025-06-05-vulnerability-reporting-process-overhaul',
'/2025/07/18/security-releases.html': '/en/blog/2025-07-18-security-releases',
'/2025/07/18/security-releases': '/en/blog/2025-07-18-security-releases',
'/2025/07/31/security-releases.html': '/en/blog/2025-07-31-security-releases',
'/2025/07/31/security-releases': '/en/blog/2025-07-31-security-releases',
'/2025/12/01/security-releases.html': '/en/blog/2025-12-01-security-releases',
'/2025/12/01/security-releases': '/en/blog/2025-12-01-security-releases',
'/2026/02/27/security-releases.html': '/en/blog/2026-02-27-security-releases',
'/2026/02/27/security-releases': '/en/blog/2026-02-27-security-releases',
'/2026/03/30/security-releases.html': '/en/blog/2026-03-30-security-releases',
'/2026/03/30/security-releases': '/en/blog/2026-03-30-security-releases',
};

const api_v2 = {
'/2x/': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/guide.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/migrate.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/screencasts.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/executables.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/contrib.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/applications.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/guide.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/migrate.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/screencasts.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/executables.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/contrib.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/applications.html': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/guide': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/migrate': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/screencasts': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/executables': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/contrib': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/applications': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/guide': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/migrate': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/screencasts': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/executables': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/contrib': 'https://github.com/expressjs/expressjs.com/tree/2x',
'/2x/docs/applications': 'https://github.com/expressjs/expressjs.com/tree/2x',
};

const pages = {
'/en/changelog/4x.html': 'https://github.com/expressjs/express/releases',
'/changelog/4x': 'https://github.com/expressjs/express/releases',
'/en/changelog/4x': 'https://github.com/expressjs/express/releases',
};

const redirects = { ...blog, ...api_v2, ...pages };
const redirects = {
...blog,
...api_v2,
...pages,
};

export default redirects;
76 changes: 76 additions & 0 deletions src/pages/[...path].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
// English redirects for every content collection.
//
// The site serves all content under `/[lang]/…`, so a bare path with no locale
// prefix (an old inbound link, or what's left after Cloudflare strips `.html`)
// has no page of its own. This catch-all enumerates the same collections the
// real routes use via `getCollection`, so the slugs always match the generated
// pages, and redirects each one to its `/en/` home.
//
// The redirect HTML is rendered by hand (rather than `Astro.redirect`) so the
// meta refresh fires instantly (`0;`) — Astro's static `Astro.redirect` helper
// hardcodes a 2-second delay, which is a poor redirect experience.
import { getCollection } from 'astro:content';
import { DEFAULT_VERSION } from '@config/versions';

export async function getStaticPaths() {
const [docs, pages, api, blog] = await Promise.all([
getCollection('docs'),
getCollection('pages'),
getCollection('api'),
getCollection('blog'),
]);

/** @type {Set<string>} */
const slugs = new Set();

/** @param {string} slug */
const add = (slug) => {
if (!slug) return;
slugs.add(slug);
// Pages served at the default version are also available unversioned,
// e.g. `5x/starter/installing` → `starter/installing`.
if (slug.startsWith(`${DEFAULT_VERSION}/`)) {
slugs.add(slug.slice(DEFAULT_VERSION.length + 1));
}
};

// `docs` (versioned guides/starter/…) and `pages` (resources, support, …)
// both embed the language as the first id segment; only English is canonical.
for (const entry of [...docs, ...pages]) {
const [lang, ...rest] = entry.id.split('/');
if (lang !== 'en') continue;
add(rest.join('/'));
}

// `api` is a shared collection with `<version>/<rest>` ids and no language.
for (const entry of api) {
add(entry.id);
}

// `blog` is served under `/[lang]/blog/<slug>`.
for (const entry of blog) {
slugs.add(`blog/${entry.id}`);
}
slugs.add('blog');

return [...slugs].map((path) => ({ params: { path } }));
}

const target = `/en/${Astro.params.path}`;
const canonical = new URL(target, Astro.site).href;
---

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Redirecting to {target}</title>
<meta http-equiv="refresh" content={`0;url=${target}`} />
<meta name="robots" content="noindex" />
<link rel="canonical" href={canonical} />
</head>
<body>
<a href={target}>Redirecting to <code>{target}</code></a>
</body>
</html>
Loading