blob: 24d0198721121b7a1db878901a3827c5004df665 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
---
import Footer from '$components/Footer.astro';
import Navbar from '$components/Navbar/Navbar.astro';
import locales, { defaultLocale } from '$i18n/locales';
import translate from '$i18n/translate';
import tFeed from '$i18n/translations/pages/rss.xml';
import site from '$i18n/translations/site';
import { getLocaleFromPathOrDefault } from '$lib/getLocaleFromPath';
import type Locale from '$types/Locale';
interface Props {
title: string;
}
const { title } = Astro.props;
const locale = getLocaleFromPathOrDefault(Astro.url.pathname);
const t = translate(locale);
function qualifiedLocalisedPath(newLocale: Locale) {
const localePathSegment = new RegExp(`^/${locale}`);
const localisedPath = Astro.url.pathname.replace(localePathSegment, newLocale);
return Astro.site + localisedPath;
}
---
<!DOCTYPE html>
<html lang={locale}>
<head>
<meta charset="UTF-8" />
<meta name="description" content={t(site, { key: 'description' })} />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" />
<link rel="sitemap" href="/sitemap-index.xml" />
<link rel="stylesheet" href="/normalize.css" />
<link rel="stylesheet" href="/main.css" />
<link
rel="alternate"
type="application/rss+xml"
title={t(tFeed, { key: 'title' })}
href={`/${locale}/rss.xml`}
/>
{
locales.map((locale) => (
<link rel="alternate" href={qualifiedLocalisedPath(locale)} hreflang={locale} />
))
}
<link rel="alternate" href={qualifiedLocalisedPath(defaultLocale)} hreflang="x-default" />
<meta name="generator" content={Astro.generator} />
<title>{title} | {t(site, { key: 'title' })}</title>
</head>
<body id="top">
<a class="btn skip-to-content" href="#main">Skip to content</a>
<Navbar />
<slot />
<Footer />
</body>
</html>
|