From 1356be248e1d1c54e339653793d65766cd53c37f Mon Sep 17 00:00:00 2001 From: Valerio Ageno Date: Sat, 4 Jan 2025 10:33:52 +0100 Subject: [PATCH] Revert "fix: catch-all server side handler" This reverts commit 7e8be92cd5959c060b4a799752407185f034b7c0. --- .../src/generator.ts | 22 ++++++++++--------- .../generator/catch_all/routeTree.expected.ts | 1 - .../catch_all/routes/posts/[...catch_all].rs | 0 3 files changed, 12 insertions(+), 11 deletions(-) delete mode 100644 packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routes/posts/[...catch_all].rs diff --git a/packages/tuono-fs-router-vite-plugin/src/generator.ts b/packages/tuono-fs-router-vite-plugin/src/generator.ts index 0d71622e..657d90f6 100644 --- a/packages/tuono-fs-router-vite-plugin/src/generator.ts +++ b/packages/tuono-fs-router-vite-plugin/src/generator.ts @@ -85,7 +85,8 @@ async function getRouteNodes( } else if (fullPath.match(/\.(rs)$/)) { const filePath = replaceBackslash(path.join(dir, dirent.name)) const filePathNoExt = removeExt(filePath) - let routePath = cleanPath(`/${filePathNoExt}`) || '' + let routePath = + cleanPath(`/${filePathNoExt.split('.').join('/')}`) || '' if (routePath === 'index') { routePath = '/' @@ -166,16 +167,17 @@ export async function routeGenerator(config = defaultConfig): Promise { const imports = [ ...sortedRouteNodes.map((node) => { const extension = node.filePath.endsWith('mdx') ? '.mdx' : '' - return `const ${node.variableName as string - }Import = dynamic(() => import('./${replaceBackslash( - removeExt( - path.relative( - path.dirname(config.generatedRouteTree), - path.resolve(config.folderName, node.filePath), - ), - false, + return `const ${ + node.variableName as string + }Import = dynamic(() => import('./${replaceBackslash( + removeExt( + path.relative( + path.dirname(config.generatedRouteTree), + path.resolve(config.folderName, node.filePath), ), - )}${extension}'))` + false, + ), + )}${extension}'))` }), ].join('\n') diff --git a/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts b/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts index 7910bdd7..a50af4c9 100644 --- a/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts +++ b/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts @@ -24,7 +24,6 @@ const IndexRoute = Index.update({ const PostscatchallRoute = Postscatchall.update({ path: '/posts/[...catch_all]', getParentRoute: () => rootRoute, - hasHandler: true, }) // Create and export the route tree diff --git a/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routes/posts/[...catch_all].rs b/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routes/posts/[...catch_all].rs deleted file mode 100644 index e69de29b..00000000