Skip to content

Commit 57a7eb6

Browse files
committed
fix: handling dynamic route layouts
1 parent 311063d commit 57a7eb6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import {
1717
ENABLE_STATIC_EXPORT_LOCALE,
1818
ENABLE_STATIC_EXPORT,
1919
} from '#site/next.constants.mjs';
20-
import { PAGE_VIEWPORT } from '#site/next.dynamic.constants.mjs';
20+
import {
21+
DYNAMIC_ROUTES,
22+
PAGE_VIEWPORT,
23+
} from '#site/next.dynamic.constants.mjs';
2124
import { dynamicRouter } from '#site/next.dynamic.mjs';
2225
import { allLocaleCodes, availableLocaleCodes } from '#site/next.locales.mjs';
2326
import { defaultLocale } from '#site/next.locales.mjs';
@@ -100,7 +103,7 @@ const getPage: FC<DynamicParams> = async props => {
100103
pathname
101104
);
102105

103-
if (source === '' && filename === '') {
106+
if (source === '' && filename === '' && !DYNAMIC_ROUTES.has(pathname)) {
104107
return notFound();
105108
}
106109

@@ -118,6 +121,8 @@ const getPage: FC<DynamicParams> = async props => {
118121
filename: filename,
119122
};
120123

124+
const layout = frontmatter.layout || DYNAMIC_ROUTES.get(pathname);
125+
121126
// Defines a shared Server Context for the Client-Side
122127
// That is shared for all pages under the dynamic router
123128
setClientContext(sharedContext);
@@ -127,7 +132,7 @@ const getPage: FC<DynamicParams> = async props => {
127132
// within a server-side context
128133
return (
129134
<MatterProvider {...sharedContext}>
130-
<WithLayout layout={frontmatter.layout}>{content}</WithLayout>
135+
<WithLayout layout={layout}>{content}</WithLayout>
131136
</MatterProvider>
132137
);
133138
};

0 commit comments

Comments
 (0)