Skip to content

feat: redirect docs root by browser language - #123

Merged
loverustfs merged 1 commit into
mainfrom
codex/browser-language-redirect
Aug 1, 2026
Merged

feat: redirect docs root by browser language#123
loverustfs merged 1 commit into
mainfrom
codex/browser-language-redirect

Conversation

@loverustfs

Copy link
Copy Markdown
Contributor

feat: redirect docs root by browser language

Copilot AI review requested due to automatic review settings August 1, 2026 16:24
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
rustfs-docs 786dc30 Commit Preview URL

Branch Preview URL
Aug 01 2026, 04:21 PM

@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-rustfs-com Ready Ready Preview Aug 1, 2026 4:24pm

@loverustfs
loverustfs merged commit 94c495c into main Aug 1, 2026
4 checks passed
@loverustfs
loverustfs deleted the codex/browser-language-redirect branch August 1, 2026 16:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a browser-language-based entry flow for the docs root (/) so visitors land on an appropriate locale while preserving a non-JS fallback language chooser page.

Changes:

  • Removes the hard-coded / -> /en redirect rule from generated redirect rules.
  • Adds a static root public/index.html + public/language-redirect.js to detect/snap to a locale and remember the user’s language preference.
  • Updates the build step to publish the new root entry page into dist/public/index.html and injects the redirect script into the global document head.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/language-redirects.mjs Stops generating a forced / redirect so root can be handled by the entry page.
scripts/add-language-redirects.mjs Copies the language entry index.html into the build output alongside _redirects.
public/language-redirect.js Implements browser-language detection + localStorage preference + SPA navigation tracking.
public/index.html Provides a root landing page that redirects by language and offers manual language links.
press.config.tsx Loads the language redirect helper on all pages to persist the selected locale.

Comment on lines +2 to +5
const supportedLanguages = new Set(["en", "zh", "de", "fr", "ja"]);
const storageKey = "rustfs-docs-language";
const getPathLanguage = () =>
window.location.pathname.match(/^\/(en|zh|de|fr|ja)(?:\/|$)/)?.[1];
Comment thread press.config.tsx
href="/favicon-16x16.png"
/>
<link rel="manifest" href="/site.webmanifest" />
<script src="/language-redirect.js" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants