diff --git a/src/components/layout/Header.astro b/src/components/layout/Header.astro
index 89b88be..67851cb 100644
--- a/src/components/layout/Header.astro
+++ b/src/components/layout/Header.astro
@@ -1,6 +1,7 @@
---
import { localizedDocsHome, localizedLandingPath } from '../../lib/locales';
import type { LanguageAlternates, Locale } from '../../lib/locales';
+import LanguageSwitcher from './LanguageSwitcher.astro';
interface Props {
locale?: Locale;
@@ -11,9 +12,6 @@ const { locale = 'vi', languageAlternates } = Astro.props;
const english = locale === 'en';
const isBlog = Astro.url.pathname.startsWith('/blog');
const home = localizedLandingPath(locale);
-const alternateLocale = english ? 'vi' : 'en';
-const alternatePath = languageAlternates?.[alternateLocale];
-const alternateLabel = english ? 'Tiếng Việt' : 'English';
const navigation = [
{ href: `${home}#experience`, label: english ? 'Explore' : 'Khám phá' },
{ href: `${home}#platforms`, label: english ? 'Platforms' : 'Nền tảng' },
@@ -42,10 +40,10 @@ const navigation = [
))}
- {alternatePath && (
-
- {alternateLabel}
-
+ {languageAlternates && (
+
+
+
)}
{english ? 'Download Funput' : 'Tải Funput'} ↓
@@ -63,10 +61,10 @@ const navigation = [
{english ? 'Privacy policy (Vietnamese)' : 'Quyền riêng tư'}
- {alternatePath && (
-
- {alternateLabel}
-
+ {languageAlternates && (
+
+
+
)}
@@ -120,11 +118,14 @@ const navigation = [
margin-left: auto;
font-size: 12px;
}
- nav a:hover,
- nav a[aria-current='page'] {
+ .desktop-nav > a:hover,
+ .mobile-menu nav > a:hover,
+ .desktop-nav > a[aria-current='page'],
+ .mobile-menu nav > a[aria-current='page'] {
color: var(--orange);
}
- nav a[aria-current='page'] {
+ .desktop-nav > a[aria-current='page'],
+ .mobile-menu nav > a[aria-current='page'] {
text-decoration: underline;
text-underline-offset: 7px;
}
@@ -133,18 +134,9 @@ const navigation = [
align-items: center;
gap: 12px;
}
- .locale-link {
- display: inline-flex;
- min-height: 44px;
- align-items: center;
- padding-inline: 6px;
- font-size: 12px;
- white-space: nowrap;
- }
- .locale-link:hover {
- color: var(--orange);
- text-decoration: underline;
- text-underline-offset: 4px;
+ .desktop-language {
+ display: flex;
+ flex: none;
}
.download-link {
font-size: 12px;
@@ -187,19 +179,35 @@ const navigation = [
border-radius: 10px;
box-shadow: 0 18px 40px #24251f18;
}
- .mobile-menu nav a {
+ .mobile-menu nav > a {
display: block;
padding: 13px;
font-size: 14px;
border-radius: 5px;
}
- .mobile-menu nav a:hover {
- background: #e8eddb;
+ .mobile-menu nav > a:hover {
+ background: var(--sage);
+ }
+ .mobile-language {
+ margin-top: 6px;
+ padding-top: 10px;
+ border-top: 1px solid var(--line);
}
@media (width > 760px) and (width <= 900px) {
- .site-header,
+ .site-header {
+ gap: 16px;
+ }
.desktop-nav {
- gap: 18px;
+ gap: 14px;
+ }
+ .nav-actions {
+ gap: 8px;
+ }
+ .download-link {
+ padding-inline: 16px;
+ }
+ .download-link span {
+ margin-left: 12px;
}
}
@media (max-width: 760px) {
@@ -208,7 +216,7 @@ const navigation = [
gap: 12px;
}
.desktop-nav,
- .locale-link {
+ .desktop-language {
display: none;
}
.mobile-menu {
diff --git a/src/components/layout/LanguageSwitcher.astro b/src/components/layout/LanguageSwitcher.astro
new file mode 100644
index 0000000..6bc6a79
--- /dev/null
+++ b/src/components/layout/LanguageSwitcher.astro
@@ -0,0 +1,98 @@
+---
+import type { LanguageAlternates, Locale } from '../../lib/locales';
+
+interface Props {
+ locale: Locale;
+ paths: LanguageAlternates;
+ wide?: boolean;
+}
+
+const { locale, paths, wide = false } = Astro.props;
+const languages = [
+ ['vi', 'Tiếng Việt'],
+ ['en', 'English'],
+] as const;
+---
+
+
+ {languages.map(([language, name]) => {
+ const current = language === locale;
+ const Option = current ? 'span' : 'a';
+ return (
+
+ );
+ })}
+
+
+