Skip to content

Commit 224b7f3

Browse files
committed
fix locale path
1 parent 8eecde6 commit 224b7f3

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

app/[locale]/[...slug]/page.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { API } from '@/components/reference/api-page';
2626
import { Badge } from '@/components/ui/badge';
2727
import * as customIcons from '@/components/ui/icon';
2828
import { TagFilterSystem } from '@/components/ui/tag-filter-system';
29+
import { i18n } from '@/lib/i18n';
2930
import { getAllFilterablePages, source } from '@/lib/source';
3031
import type { HeadingProps } from '@/types';
3132

@@ -298,20 +299,31 @@ export default async function Page(props: {
298299
}
299300

300301
export async function generateStaticParams() {
301-
// Generate params for both locales and slugs
302+
const { languages, defaultLanguage } = i18n;
303+
304+
// Generate params for all locales and slugs
302305
const slugParams = source.generateParams().filter(
303306
(params) =>
304-
// Filter out empty slug arrays (root path)
305307
params.slug && params.slug.length > 0,
306308
);
307309

308-
// The source slugs include 'en' as first element, we need to extract it
309-
return slugParams
310-
.filter((params) => params.slug[0] === 'en') // Only handle 'en' for now
311-
.map((params) => ({
312-
locale: 'en',
313-
slug: params.slug.slice(1), // Remove the 'en' prefix from slug
314-
}));
310+
const allParams = [];
311+
312+
for (const params of slugParams) {
313+
const [sourceLocale, ...restSlug] = params.slug;
314+
315+
// Generate for all configured locales
316+
if (sourceLocale === defaultLanguage) {
317+
for (const locale of languages) {
318+
allParams.push({
319+
locale,
320+
slug: restSlug,
321+
});
322+
}
323+
}
324+
}
325+
326+
return allParams;
315327
}
316328

317329
export async function generateMetadata(props: {
@@ -322,7 +334,7 @@ export async function generateMetadata(props: {
322334
}) {
323335
const params = await props.params;
324336
const { locale, slug } = params;
325-
// The source includes 'en' in the slug path, so we need to prepend it
337+
// The source includes [locale] in the slug path, so we need to prepend it
326338
const fullSlug = [locale, ...slug];
327339
const page = source.getPage(fullSlug);
328340
if (!page) notFound();

0 commit comments

Comments
 (0)