Skip to content

Commit

Permalink
refactor: add alternate urls
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed Nov 6, 2024
1 parent 3ad07e4 commit 6cf9ba6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
import { AstroSeo } from "@astrolib/seo";
import { getLocale } from "astro-i18n-aut";
import {
defaultLocale,
getLocale,
getLocaleUrl,
locales,
} from "astro-i18n-aut";
import { getPhrases } from "../phrases";
type Props = {
Expand Down Expand Up @@ -31,6 +36,20 @@ const canonical = new URL(Astro.url.pathname, Astro.site).href;
url: canonical,
site_name: "Auth Wiki",
}}
languageAlternates={[
...Object.keys(locales).map((lang) => ({
hreflang: lang,
href: new URL(getLocaleUrl(Astro.url.pathname, lang), Astro.site)
.href,
})),
{
hreflang: "x-default",
href: new URL(
getLocaleUrl(Astro.url.pathname, defaultLocale),
Astro.site,
).href,
},
]}
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
Expand Down

0 comments on commit 6cf9ba6

Please sign in to comment.