refactor(routes): load route templates with fs/promises

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/5341/head
Divyansh Singh 1 week ago
parent f53f00a01c
commit b1636e9f89

@ -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

Loading…
Cancel
Save