|
1 | 1 | --- |
2 | | -import { getEntry } from "astro:content"; |
| 2 | +import { getCollectionInLocaleWithFallbacks } from "@pages/_utils"; |
3 | 3 | import AboutLayout from "@layouts/AboutLayout.astro"; |
4 | | -import { defaultLocale } from "../../i18n/const"; |
| 4 | +import { nonDefaultSupportedLocales, defaultLocale } from "@i18n/const"; |
5 | 5 | import { setJumpToState } from "../../globals/state"; |
6 | | -import { nonDefaultSupportedLocales } from "@/src/i18n/const"; |
| 6 | +import type { CollectionEntry } from "astro:content"; |
7 | 7 |
|
8 | | -export const getStaticPaths = async () => { |
9 | | - const defaultAboutEntry = await getEntry( |
10 | | - "text-detail", |
11 | | - `${defaultLocale}/about` |
12 | | - )!; |
13 | | - const pages = await Promise.all( |
14 | | - nonDefaultSupportedLocales.map(async (locale) => { |
15 | | - const aboutEntry = await getEntry("text-detail", `${locale}/about`); |
16 | | - return { |
17 | | - params: { locale }, |
18 | | - props: { |
19 | | - entry: aboutEntry ?? defaultAboutEntry, |
20 | | - }, |
21 | | - }; |
22 | | - }) |
23 | | - ); |
24 | | - return pages; |
25 | | -}; |
| 8 | +export async function getStaticPaths() { |
| 9 | + const pages = nonDefaultSupportedLocales.map(async (locale) => { |
| 10 | + const entries = await getCollectionInLocaleWithFallbacks( |
| 11 | + "text-detail", |
| 12 | + locale |
| 13 | + ); |
| 14 | + const aboutEntry = entries.find(entry => |
| 15 | + entry.id.endsWith('/about.mdx') || |
| 16 | + entry.id === `${defaultLocale}/about.mdx` |
| 17 | + ) as CollectionEntry<"text-detail">; |
| 18 | +
|
| 19 | + return { |
| 20 | + params: { locale }, |
| 21 | + props: { entry: aboutEntry }, |
| 22 | + }; |
| 23 | + }); |
| 24 | +
|
| 25 | + return await Promise.all(pages); |
| 26 | +} |
26 | 27 |
|
27 | 28 | const { entry } = Astro.props; |
28 | 29 | setJumpToState(null); |
|
0 commit comments