From dc53086c1e73d43d3a28fc4cdf161e83d09b1877 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Mon, 9 Feb 2026 11:34:35 -0600 Subject: wip(docs): i18n (#12681) --- packages/web/src/components/Header.astro | 228 ++++++++++++++++--------------- 1 file changed, 118 insertions(+), 110 deletions(-) (limited to 'packages/web/src/components/Header.astro') diff --git a/packages/web/src/components/Header.astro b/packages/web/src/components/Header.astro index 396200a3e..bb13c9117 100644 --- a/packages/web/src/components/Header.astro +++ b/packages/web/src/components/Header.astro @@ -1,128 +1,136 @@ --- -import config from '../../config.mjs'; -import astroConfig from 'virtual:starlight/user-config'; -import { Icon } from '@astrojs/starlight/components'; -import { HeaderLinks } from 'toolbeam-docs-theme/components'; -import Default from 'toolbeam-docs-theme/overrides/Header.astro'; -import SocialIcons from 'virtual:starlight/components/SocialIcons'; -import SiteTitle from '@astrojs/starlight/components/SiteTitle.astro'; +import config from "../../config.mjs" +import astroConfig from "virtual:starlight/user-config" +import { getRelativeLocaleUrl } from "astro:i18n" +import { Icon } from "@astrojs/starlight/components" +import Default from "toolbeam-docs-theme/overrides/Header.astro" +import SiteTitle from "@astrojs/starlight/components/SiteTitle.astro" -const path = Astro.url.pathname; - -const links = astroConfig.social || []; -const headerLinks = config.headerLinks; +const path = Astro.url.pathname +const locale = Astro.currentLocale || "root" +const route = Astro.locals.starlightRoute +const t = Astro.locals.t as (key: string) => string +const links = astroConfig.social || [] +const headerLinks = config.headerLinks +const sharePath = /\/s(\/|$)/.test(path) +function href(url: string) { + if (url === "/" || url === "/docs" || url === "/docs/") { + return getRelativeLocaleUrl(locale, "") + } + return url +} --- -{ path.startsWith("/s") -?
-
- -
-
- { - headerLinks?.map(({ name, url }) => ( - {name} - )) - } -
-
- { - links.length > 0 && ( - - ) - } -
-
- : -} +{sharePath ? ( +
+
+ +
+
+ {headerLinks?.map(({ name, url }) => ( + {t(name)} + ))} +
+
+ {links.length > 0 && ( + + )} +
+
+) : ( + +)} + -- cgit v1.2.3