File tree 8 files changed +28
-12
lines changed
8 files changed +28
-12
lines changed Original file line number Diff line number Diff line change 2
2
interface Props {}
3
3
4
4
import { useTranslations } from " ../i18n/utils" ;
5
+ import type { Params } from " ../i18n/utils" ;
5
6
import { Image } from " astro:assets" ;
6
7
import aux from " ../../public/aux.svg" ;
7
8
8
- const { lang } = Astro .params ;
9
+ const { lang } = Astro .params as Params ;
9
10
const translation = useTranslations (lang );
10
11
---
11
12
Original file line number Diff line number Diff line change 1
1
---
2
2
import { useTranslations } from " ../../i18n/utils" ;
3
+ import type { Params } from " ../../i18n/utils" ;
3
4
4
- const { lang } = Astro .params ;
5
+ const { lang } = Astro .params as Params ;
5
6
const translation = useTranslations (lang );
6
7
---
7
8
Original file line number Diff line number Diff line change 2
2
import { useTranslations } from " ../../i18n/utils" ;
3
3
import { Image } from " astro:assets" ;
4
4
import aux from " ../../../public/aux.svg" ;
5
+ import type { Params } from " ../../i18n/utils" ;
5
6
6
- const { lang } = Astro .params ;
7
+ const { lang } = Astro .params as Params ;
7
8
const translation = useTranslations (lang );
8
9
---
9
10
Original file line number Diff line number Diff line change 1
1
---
2
2
import { useTranslations } from " ../../i18n/utils" ;
3
+ import type { Params } from " ../../i18n/utils" ;
3
4
4
- const { lang } = Astro .params ;
5
+ const { lang } = Astro .params as Params ;
5
6
const translation = useTranslations (lang );
6
7
---
7
8
Original file line number Diff line number Diff line change 1
1
---
2
2
import { useTranslations } from " ../../i18n/utils" ;
3
+ import type { Params } from " ../../i18n/utils" ;
3
4
4
- const { lang } = Astro .params ;
5
+ const { lang } = Astro .params as Params ;
5
6
const translation = useTranslations (lang );
6
7
---
7
8
Original file line number Diff line number Diff line change 1
- import { ui , defaultLang } from "./ui" ;
1
+ import { ui , defaultLang , languages } from "./ui" ;
2
+ import type {
3
+ InferGetStaticParamsType ,
4
+ InferGetStaticPropsType ,
5
+ GetStaticPaths ,
6
+ } from "astro" ;
2
7
3
8
export function useTranslations ( lang : keyof typeof ui ) {
4
9
return function t ( key : keyof ( typeof ui ) [ typeof defaultLang ] ) {
5
10
return ui [ lang ] [ key ] || ui [ defaultLang ] [ key ] ;
6
11
} ;
7
12
}
13
+
14
+ export const getStaticPaths = ( async ( ) => {
15
+ return Object . keys ( languages ) . map ( ( name ) => ( {
16
+ params : { lang : name as keyof typeof languages } ,
17
+ } ) ) ;
18
+ } ) satisfies GetStaticPaths ;
19
+
20
+ export type Params = InferGetStaticParamsType < typeof getStaticPaths > ;
21
+ export type Props = InferGetStaticPropsType < typeof getStaticPaths > ;
Original file line number Diff line number Diff line change 1
1
---
2
2
import Header from " ../components/Header.astro" ;
3
+ import type { Params } from " ../i18n/utils" ;
3
4
4
5
interface Props {
5
6
title: string ;
6
7
}
7
8
8
9
const { title } = Astro .props ;
9
- const { lang } = Astro .params ;
10
+ const { lang } = Astro .params as Params ;
10
11
---
11
12
12
13
<!doctype html >
Original file line number Diff line number Diff line change 1
1
---
2
- import { languages } from " ../../i18n/ui" ;
3
2
import Layout from " ../../layouts/Layout.astro" ;
4
3
import Home from " ../../components/home/Home.astro" ;
5
-
6
- export async function getStaticPaths() {
7
- return Object .keys (languages ).map ((name ) => ({ params: { lang: name } }));
8
- }
4
+ export { getStaticPaths } from " ../../i18n/utils" ;
9
5
---
10
6
11
7
<Layout title =" auxolotl.org" >
You can’t perform that action at this time.
0 commit comments