mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: start adding pwa
This commit is contained in:
1 parent
080f0a0eb7
commit
01755a2a64
15 files changed
+141
-54
No files matched your search
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
---
|
||||
import { localizedHTML as favicons } from "astro-favicons/middleware";
|
||||
---
|
||||
|
||||
<Fragment set:html={favicons(Astro.currentLocale)} />
|
||||
@@ -0,0 +1,25 @@
|
||||
<script>
|
||||
import { SUPPORTED_LOCALES } from "@blitzkit/i18n";
|
||||
import { getBestLocale } from "../core/i18n/getBestLocale";
|
||||
const isAPI = window.location.pathname.startsWith("/api");
|
||||
const isI18nPath = SUPPORTED_LOCALES.some((locale) =>
|
||||
window.location.pathname.startsWith(`/${locale}`)
|
||||
);
|
||||
const bestLocale = getBestLocale();
|
||||
const currentPathLocale = SUPPORTED_LOCALES.find((locale) =>
|
||||
window.location.pathname.startsWith(`/${locale}`)
|
||||
);
|
||||
|
||||
if (
|
||||
!isAPI && // not an api, duh!
|
||||
localStorage.getItem("preferred-locale") !== null && // no preference, so probably google's crawler
|
||||
bestLocale !== currentPathLocale // we need to redirect
|
||||
) {
|
||||
window.location.pathname = isI18nPath
|
||||
? window.location.pathname.replace(
|
||||
`/${currentPathLocale}`,
|
||||
bestLocale === undefined ? "" : `/${bestLocale}`
|
||||
)
|
||||
: `/${bestLocale}${window.location.pathname}`;
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,3 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||
Whitespace-only changes.
Reference in new issue
Block a user