diff --git a/src/node/plugins/dynamicRoutesPlugin.ts b/src/node/plugins/dynamicRoutesPlugin.ts index b4f1edb0..69f7c03d 100644 --- a/src/node/plugins/dynamicRoutesPlugin.ts +++ b/src/node/plugins/dynamicRoutesPlugin.ts @@ -1,4 +1,5 @@ import fs from 'node:fs' +import { readFile } from 'node:fs/promises' import path from 'node:path' import c from 'picocolors' import pm from 'picomatch' @@ -148,7 +149,7 @@ export const dynamicRoutesPlugin = async ( load: { filter: { id: /\.md$/ }, - handler(id) { + async handler(id) { const matched = config.dynamicRoutes.find((r) => r.fullPath === id) if (matched) { const { route, params, content } = matched @@ -157,7 +158,7 @@ export const dynamicRoutesPlugin = async ( moduleGraph.add(id, [routeFile]) moduleGraph.add(routeFile, [matched.loaderPath]) - let baseContent = fs.readFileSync(routeFile, 'utf8') + let baseContent = await readFile(routeFile, 'utf8') // inject raw content // this is intended for integration with CMS