Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 498168f

Browse files
committed
fix(preview): remove prefix when parsing files
1 parent 2579910 commit 498168f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/runtime/internal/preview/compatibility.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ export const v2ToV3ParsedFile = (file: DraftSyncFile, collection: CollectionInfo
88
if (!file.parsed) {
99
return undefined
1010
}
11-
const path = file.parsed._path!.substring(fixed.length)
12-
const pathInCollection = join(source?.prefix || '', path)
11+
12+
const fixedWithoutPrefix = fixed.replace(/^\d+\./, '')
13+
const prefixWithoutPrefix = (source?.prefix || '').replace(/\/\d+\./, '/')
14+
const path = file.parsed._path!.substring(fixedWithoutPrefix.length)
15+
const pathInCollection = join(prefixWithoutPrefix, path)
1316

1417
// TODO - Handle data collections (remove path...)
1518
const mappedFile: Record<string, unknown> = {

0 commit comments

Comments
 (0)