fix(data collections): normalize file paths for DataEntry.id (#8144)

* normalize file paths for DataEntry.id

* add changeset
This commit is contained in:
Arsh 2023-08-19 01:12:53 +05:30 committed by GitHub
parent e3c030e5d3
commit 04caa99c48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixed an issue where data entries' id included backslashes instead of forward slashes on Windows.

View file

@ -209,7 +209,7 @@ export function getDataEntryId({
collection,
}: Pick<ContentPaths, 'contentDir'> & { entry: URL; collection: string }): string {
const relativePath = getRelativeEntryPath(entry, collection, contentDir);
const withoutFileExt = relativePath.replace(new RegExp(path.extname(relativePath) + '$'), '');
const withoutFileExt = normalizePath(relativePath).replace(new RegExp(path.extname(relativePath) + '$'), '');
return withoutFileExt;
}