Skip to content

Commit 04caa99

Browse files
authored
fix(data collections): normalize file paths for DataEntry.id (#8144)
* normalize file paths for DataEntry.id * add changeset
1 parent e3c030e commit 04caa99

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixed an issue where data entries' id included backslashes instead of forward slashes on Windows.

packages/astro/src/content/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export function getDataEntryId({
209209
collection,
210210
}: Pick<ContentPaths, 'contentDir'> & { entry: URL; collection: string }): string {
211211
const relativePath = getRelativeEntryPath(entry, collection, contentDir);
212-
const withoutFileExt = relativePath.replace(new RegExp(path.extname(relativePath) + '$'), '');
212+
const withoutFileExt = normalizePath(relativePath).replace(new RegExp(path.extname(relativePath) + '$'), '');
213213

214214
return withoutFileExt;
215215
}

0 commit comments

Comments
 (0)