Skip to content

Commit

Permalink
fix(i18nRedirector): hashを含めるように
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Dec 5, 2024
1 parent 7e42779 commit 2664849
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions .vitepress/scripts/gen-i18n-redirector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ts-expect-error Node
import fs from 'fs';
import { mainLocale, baseUrl } from '../config';
import type { SiteConfig } from 'vitepress';
Expand Down Expand Up @@ -31,7 +30,7 @@ export async function genI18nRedirector(siteConfig: SiteConfig) {
${linkAlternate}
<link rel="alternate" hreflang="x-default" href="${baseUrl}/${mainLocale}/${routeForRender}">
<link rel="canonical" href="${baseUrl}/${mainLocale}/${routeForRender}">
<script type="text/javascript">const s = ${JSON.stringify(localeNames)}; const d = localStorage.getItem('ais:locale'); if (d) { location.replace('/' + d + location.pathname + location.search); } else if (s.includes(navigator.language.split("-")[0])) { location.replace('/' + navigator.language.split("-")[0] + location.pathname + location.search); } else { location.replace('/ja' + location.pathname + location.search); }</script>
<script type="text/javascript">const s = ${JSON.stringify(localeNames)}; const d = localStorage.getItem('ais:locale'); if (d) { location.replace('/' + d + location.pathname + location.search + location.hash); } else if (s.includes(navigator.language.split("-")[0])) { location.replace('/' + navigator.language.split("-")[0] + location.pathname + location.search + location.hash); } else { location.replace('/ja' + location.pathname + location.search + location.hash); }</script>
</head>
<body>
<noscript>${fallbackLinks}</noscript>
Expand Down

0 comments on commit 2664849

Please sign in to comment.