Skip to content

Commit d5c5689

Browse files
Copilotneilime
andcommitted
Refactor navigation: remove defaults, use typed locale, remove backward compatibility
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
1 parent fc839c2 commit d5c5689

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

application/src/layouts/LandingLayout.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
import PageLayout from '~/layouts/PageLayout.astro';
33
import Header from '~/components/widgets/Header.astro';
44
5-
import { headerData } from '~/navigation';
5+
import { getHeaderData } from '~/navigation';
6+
import { getLangFromUrl } from '~/i18n/utils';
67
import type { MetaData } from '~/types';
78
89
export interface Props {
910
metadata?: MetaData;
1011
}
1112
1213
const { metadata } = Astro.props;
14+
const currentLang = getLangFromUrl(Astro.url);
15+
const headerData = getHeaderData(currentLang);
1316
---
1417

1518
<PageLayout metadata={metadata}>

application/src/navigation.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { getPermalink } from './utils/permalinks';
22
import { useTranslations } from './i18n/utils';
3+
import type { ui } from './i18n/ui';
34
import favIcon from '~/assets/favicons/favicon.svg';
45

56
// Function to get locale-aware navigation
6-
export const getHeaderData = (locale: string = 'fr') => {
7-
const t = useTranslations(locale as 'fr' | 'en');
7+
export const getHeaderData = (locale: keyof typeof ui) => {
8+
const t = useTranslations(locale);
89

910
return {
1011
links: [
@@ -24,8 +25,8 @@ export const getHeaderData = (locale: string = 'fr') => {
2425
};
2526
};
2627

27-
export const getFooterData = (locale: string = 'fr') => {
28-
const t = useTranslations(locale as 'fr' | 'en');
28+
export const getFooterData = (locale: keyof typeof ui) => {
29+
const t = useTranslations(locale);
2930

3031
return {
3132
links: [
@@ -58,7 +59,3 @@ export const getFooterData = (locale: string = 'fr') => {
5859
};
5960
};
6061

61-
// Keep backward compatibility - default to French
62-
export const headerData = getHeaderData('fr');
63-
export const footerData = getFooterData('fr');
64-

application/src/pages/homes/saas.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ import Steps2 from '~/components/widgets/Steps2.astro';
88
import Content from '~/components/widgets/Content.astro';
99
import Pricing from '~/components/widgets/Pricing.astro';
1010
11-
import { headerData } from '~/navigation';
11+
import { getHeaderData } from '~/navigation';
12+
import { getLangFromUrl } from '~/i18n/utils';
1213
import FAQs from '~/components/widgets/FAQs.astro';
1314
import BlogLatestPosts from '~/components/widgets/BlogLatestPosts.astro';
1415
16+
const currentLang = getLangFromUrl(Astro.url);
17+
const headerData = getHeaderData(currentLang);
18+
1519
const metadata = {
1620
title: 'SaaS Landing Page',
1721
};

0 commit comments

Comments
 (0)