summaryrefslogtreecommitdiff
path: root/src/components/BaseHead.astro
blob: 2e5a9cdea235ec244d172493b55bb612dd8d7b7b (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
import { siteConfig } from "@/site.config";
import type { SiteMeta } from "@/types";
import "@/styles/global.css";

type Props = SiteMeta;

const { articleDate, description, ogImage, title, lang } = Astro.props;

const titleSeparator = "•";
const siteTitle = `${title} ${titleSeparator} ${siteConfig.title}`;
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url).href;

// Map ISO 639-1 language codes to og:locale format
function getOgLocale(langCode?: string): string {
	if (!langCode) return siteConfig.ogLocale;

	const localeMap: Record<string, string> = {
		en: "en_US",
		pl: "pl_PL",
		es: "es_ES",
		fr: "fr_FR",
		de: "de_DE",
		it: "it_IT",
		pt: "pt_PT",
		nl: "nl_NL",
		ru: "ru_RU",
		ja: "ja_JP",
		zh: "zh_CN",
		ko: "ko_KR",
	};

	return localeMap[langCode] || siteConfig.ogLocale;
}

const ogLocale = getOgLocale(lang);
---

<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>{siteTitle}</title>

{/* Icons */}
<link href="/icon.svg" rel="icon" type="image/svg+xml" />
{
	import.meta.env.PROD && (
		<>
			{/* Favicon & Apple Icon */}
			<link rel="icon" href="/favicon-32x32.png" type="image/png" />
			<link href="/icons/apple-touch-icon.png" rel="apple-touch-icon" />
			{/* Manifest */}
			<link href="/manifest.webmanifest" rel="manifest" />
		</>
	)
}

{/* Canonical URL */}
<link href={canonicalURL} rel="canonical" />

{/* Primary Meta Tags */}
<meta content={siteTitle} name="title" />
<meta content={description} name="description" />
<meta content={siteConfig.author} name="author" />

{/* Open Graph / Facebook */}
<meta content={articleDate ? "article" : "website"} property="og:type" />
<meta content={title} property="og:title" />
<meta content={description} property="og:description" />
<meta content={canonicalURL} property="og:url" />
<meta content={siteConfig.title} property="og:site_name" />
<meta content={ogLocale} property="og:locale" />
<meta content={socialImageURL} property="og:image" />
<meta content="1200" property="og:image:width" />
<meta content="630" property="og:image:height" />
{
	articleDate && (
		<>
			<meta content={siteConfig.author} property="article:author" />
			<meta content={articleDate} property="article:published_time" />
		</>
	)
}

{/* Twitter */}
<meta content="summary_large_image" property="twitter:card" />
<meta content={canonicalURL} property="twitter:url" />
<meta content={title} property="twitter:title" />
<meta content={description} property="twitter:description" />
<meta content={socialImageURL} property="twitter:image" />

{/* Sitemap */}
<link href="/sitemap-index.xml" rel="sitemap" />

{/* RSS auto-discovery */}
<link href="/rss.xml" title="Blog" rel="alternate" type="application/rss+xml" />

{/* Plausible Analytics */}
<link rel="dns-prefetch" href="//analytics.craftknight.com" />
<script
	is:inline
	type="text/javascript"
	defer
	data-domain="rycerz.xyz"
	data-api="https://analytics.craftknight.com/api/event"
	data-cfasync="false"
	src="https://analytics.craftknight.com/js/plausible.outbound-links.js?ver=2.1.3"
	id="plausible"></script>
<script is:inline type="text/javascript" id="plausible-analytics-js-after">
	/* <![CDATA[ */
	window.plausible =
		window.plausible ||
		function () {
			(window.plausible.q = window.plausible.q || []).push(arguments);
		};
	/* ]]> */
</script>

<meta content={Astro.generator} name="generator" />