Files
blitzkit/packages/website/src/layouts/BaseLayout.astro
T
2025-01-17 19:06:07 -06:00

67 lines
1.9 KiB
Plaintext

---
import { Flex } from '@radix-ui/themes';
import { BlitzKitTheme } from '../components/BlitzKitTheme';
import { Checks } from '../components/Checks';
import Footer from '../components/Footer.astro';
import Navbar from '../components/Navbar.astro';
import Party3 from '../components/Party3.astro';
import './base.css';
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
export interface Props {
noFooter?: boolean;
}
const { noFooter } = Astro.props;
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
---
<html lang={locale}>
<head>
<meta property="og:site_name" content="BlitzKit" />
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="sitemap" href="/sitemap-index.xml" />
<Party3 />
<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 && bestLocale !== currentPathLocale) {
window.location.pathname = isI18nPath
? window.location.pathname.replace(
`/${currentPathLocale}`,
bestLocale === undefined ? '' : `/${bestLocale}`,
)
: `/${bestLocale}${window.location.pathname}`;
}
</script>
</head>
<body>
<BlitzKitTheme>
<Flex direction="column" minHeight="100vh">
<Navbar />
<Checks {locale} client:only="react" />
<slot />
{!noFooter && <Footer />}
</Flex>
</BlitzKitTheme>
</body>
</html>