Skip to content

Commit

Permalink
fix(data collections): normalize file paths for DataEntry.id (#8144)
Browse files Browse the repository at this point in the history
* normalize file paths for DataEntry.id

* add changeset
  • Loading branch information
lilnasy authored Aug 18, 2023
1 parent e3c030e commit 04caa99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twenty-mirrors-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixed an issue where data entries' id included backslashes instead of forward slashes on Windows.
2 changes: 1 addition & 1 deletion packages/astro/src/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 04caa99

Please sign in to comment.