Skip to content

Commit e048a55

Browse files
committed
fix(hooks): generate missing dirname & extension in vFile
resolves #2970
1 parent 164ffb0 commit e048a55

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/content/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ export async function createParser(collection: ResolvedCollection, nuxt?: Nuxt)
130130
}
131131

132132
return async function parse(file: ContentFile) {
133-
if (file.path && !file.dirname) {
134-
file.dirname = dirname(file.path)
133+
if (file.path) {
134+
file.dirname = file.dirname ?? dirname(file.path)
135+
file.extension = file.extension ?? file.path.split('.').pop()
135136
}
136137
const beforeParseCtx: FileBeforeParseHook = { file, collection, parserOptions }
137138
// @ts-expect-error runtime type

0 commit comments

Comments
 (0)