diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2026-01-12 20:50:47 +0100 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2026-01-12 20:51:33 +0100 |
| commit | 686ccbfd2ed51723f4df79ba0b976e0f5fafce2f (patch) | |
| tree | 291ebb0d97b6dfb18f1f0bc86418326e0f40edd5 /src/components/BaseHead.astro | |
| parent | 4171c2204fb43f5d7483b8e42432519b69bdef1f (diff) | |
Fix pages languages
Diffstat (limited to 'src/components/BaseHead.astro')
| -rw-r--r-- | src/components/BaseHead.astro | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index cb39d4a..40f1d20 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -6,12 +6,36 @@ import "@/styles/global.css"; type Props = SiteMeta; -const { articleDate, description, ogImage, title } = Astro.props; +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" /> @@ -46,7 +70,7 @@ const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url <meta content={description} property="og:description" /> <meta content={canonicalURL} property="og:url" /> <meta content={siteConfig.title} property="og:site_name" /> -<meta content={siteConfig.ogLocale} property="og:locale" /> +<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" /> |
