diff --git a/astro.config.mjs b/astro.config.mjs index 391d5ec..c70af5d 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -10,6 +10,7 @@ import { unified } from "@astrojs/markdown-remark"; import { h } from "hastscript"; import { visit } from "unist-util-visit"; import sitemap from "@astrojs/sitemap"; +import { LOCALES, DEFAULT_LOCALE, normalizeLangTag } from "./src/lib/i18n"; const rehypeTrimTrailingDashes = () => (tree) => { const walk = (node) => { @@ -100,6 +101,9 @@ export function rehypeAutoVideo() { }; } +const locales = {}; +LOCALES.forEach((locale) => (locales[locale] = normalizeLangTag(locale))); + // https://astro.build/config export default defineConfig({ site: "https://andromeda.zenfyr.dev", @@ -122,5 +126,12 @@ export default defineConfig({ }), }, - integrations: [sitemap()], + integrations: [ + sitemap({ + i18n: { + defaultLocale: DEFAULT_LOCALE, + locales: locales, + }, + }), + ], }); diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index 2f29fc9..687de7f 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -5,11 +5,12 @@ import "katex/dist/katex.min.css"; interface Props { title: string; + canonical?: string; description?: string; tags?: string[]; } -const { title, description, tags = [] } = Astro.props; +const { title, description, canonical, tags = [] } = Astro.props; --- @@ -20,6 +21,8 @@ const { title, description, tags = [] } = Astro.props; + {canonical && } + {title} {description && } diff --git a/src/layouts/BasePage.astro b/src/layouts/BasePage.astro index 8ca0860..226efab 100644 --- a/src/layouts/BasePage.astro +++ b/src/layouts/BasePage.astro @@ -7,16 +7,17 @@ import "./base.css"; type Props = { title: string; locale: string; + canonical?: string; tags?: string[]; description?: string; }; -const { title, locale, tags, description } = Astro.props; +const { title, locale, tags, description, canonical } = Astro.props; const lang = normalizeLangTag(locale); --- - +