We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 630d29e commit 25aeabfCopy full SHA for 25aeabf
1 file changed
docs/src/components/Head.astro
@@ -8,6 +8,20 @@ const props = Astro.props;
8
<StarlightHead {...props} />
9
<ClientRouter />
10
11
+<script is:inline>
12
+ (function() {
13
+ // Only redirect on root (zh) pages, not already on /en/
14
+ if (window.location.pathname.startsWith('/en')) return;
15
+ // Only redirect once per session
16
+ if (sessionStorage.getItem('lang-redirected')) return;
17
+ var lang = navigator.language || navigator.userLanguage || '';
18
+ if (!lang.startsWith('zh')) {
19
+ sessionStorage.setItem('lang-redirected', '1');
20
+ window.location.replace('/en' + window.location.pathname);
21
+ }
22
+ })();
23
+</script>
24
+
25
<script>
26
import mediumZoom from 'medium-zoom';
27
0 commit comments