Skip to content

Commit 6c8782f

Browse files
committed
fix: fixed route generation
1 parent dd33d07 commit 6c8782f

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

  • apps/site/app/[locale]/blog/[...path]

apps/site/app/[locale]/blog/[...path]/page.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@ const BLOG_DYNAMIC_ROUTES = blogData.categories.flatMap(category => {
2727
// Each category can have multiple pages, so we generate a route for each page
2828
const categoryPages = provideBlogPosts(category).pagination.pages;
2929

30-
const categoryRoutes = Array.from({ length: categoryPages }, (_, page) => ({
30+
const categoryRoute = {
3131
locale: defaultLocale.code,
32-
path: [category, `${category}/page/${page + 1}`],
33-
}));
32+
path: [category],
33+
pathname: `${category}`,
34+
};
35+
36+
const categoryPaginationRoutes = Array.from(
37+
{ length: categoryPages },
38+
(_, page) => ({
39+
locale: defaultLocale.code,
40+
path: [category, 'page', `${page + 1}`],
41+
pathname: `${category}/page/${page + 1}`,
42+
})
43+
);
3444

35-
return [{ locale: defaultLocale.code, path: [category] }, ...categoryRoutes];
45+
return [categoryRoute, ...categoryPaginationRoutes];
3646
});
3747

3848
// This is the default Viewport Metadata
@@ -66,7 +76,7 @@ const getPage: FC<DynamicParams> = async props => {
6676
const [locale, pathname] = await basePage.getLocaleAndPath(props);
6777

6878
const isDynamicRoute = BLOG_DYNAMIC_ROUTES.some(route =>
69-
route.path.includes(pathname)
79+
route.pathname.includes(pathname)
7080
);
7181

7282
// Gets the Markdown content and context for Blog pages

0 commit comments

Comments
 (0)