We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c9c393a commit c747d76Copy full SHA for c747d76
src/App.tsx
@@ -17,7 +17,13 @@ const App: React.FC = () => {
17
.toLowerCase(); // ルートパスを小文字に変換
18
19
// 最も近いLayoutを探す
20
- const layoutPath = Object.keys(layouts).find(layoutPath => path.startsWith(layoutPath.replace('/Layout.tsx', '')));
+ const layoutPath = Object.keys(layouts).reduce((closest, layoutPath) => {
21
+ if (path.startsWith(layoutPath.replace('/Layout.tsx', ''))) {
22
+ return layoutPath.length > (closest?.length || 0) ? layoutPath : closest;
23
+ }
24
+ return closest;
25
+ }, undefined as string | undefined);
26
+
27
const LayoutComponent = layoutPath ? (layouts[layoutPath] as { default: React.ComponentType<any> }).default : React.Fragment;
28
29
return (
src/routes/a/[id].tsx src/routes/a/[id]/[id].tsxsrc/routes/a/[id].tsx renamed to src/routes/a/[id]/[id].tsx
0 commit comments