Skip to content

Commit

Permalink
fix: content types reference to config on windows (#9877)
Browse files Browse the repository at this point in the history
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
  • Loading branch information
fabiankachlock and florian-lefebvre authored Jan 31, 2024
1 parent 38e40f1 commit 7be5f94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/funny-mice-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes the content config type path on windows
4 changes: 3 additions & 1 deletion packages/astro/src/content/types-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ function invalidateVirtualMod(viteServer: ViteDevServer) {
*/
function normalizeConfigPath(from: string, to: string) {
const configPath = path.relative(from, to).replace(/\.ts$/, '.js');
// on windows `path.relative` will use backslashes, these must be replaced with forward slashes
const normalizedPath = configPath.replaceAll('\\', '/');

return `"${isRelativePath(configPath) ? '' : './'}${configPath}"` as const;
return `"${isRelativePath(configPath) ? '' : './'}${normalizedPath}"` as const;
}

async function writeContentFiles({
Expand Down

0 comments on commit 7be5f94

Please sign in to comment.