diff --git a/src/node/plugins/dynamicRoutesPlugin.ts b/src/node/plugins/dynamicRoutesPlugin.ts index f24ebe6b..5003af23 100644 --- a/src/node/plugins/dynamicRoutesPlugin.ts +++ b/src/node/plugins/dynamicRoutesPlugin.ts @@ -27,10 +27,14 @@ export async function resolvePages(srcDir: string, userConfig: UserConfig) { }) ).sort() - const pages = allMarkdownFiles.filter((p) => !dynamicRouteRE.test(p)) - const dynamicRouteFiles = allMarkdownFiles.filter((p) => - dynamicRouteRE.test(p) - ) + const pages: string[] = [] + const dynamicRouteFiles: string[] = [] + + allMarkdownFiles.forEach((file) => { + dynamicRouteRE.lastIndex = 0 + ;(dynamicRouteRE.test(file) ? dynamicRouteFiles : pages).push(file) + }) + const dynamicRoutes = await resolveDynamicRoutes(srcDir, dynamicRouteFiles) pages.push(...dynamicRoutes.routes.map((r) => r.path))