-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Content Collections not loading config file when there are spaces…
… in the folder tree (#5962) * fix * add test * use `fileURLToPath` instead * chore: changeset * remove useless config file * revert back to using `decodeURIComponent` * test: better test * re-revert back to using `fileURLToPath`
- Loading branch information
1 parent
e7f9696
commit 46b6e14
Showing
7 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix Content Collections not loading config file when there are spaces in the folder tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/content with spaces in folder name/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/content-with-spaces-in-folder-name", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/mdx": "workspace:*" | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/astro/test/fixtures/content with spaces in folder name/src/content/config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { z, defineCollection } from 'astro:content'; | ||
|
||
const withCustomSlugs = defineCollection({ | ||
schema: z.object({}), | ||
}); | ||
|
||
const withSchemaConfig = defineCollection({ | ||
schema: z.object({ | ||
title: z.string(), | ||
isDraft: z.boolean().default(false), | ||
lang: z.enum(['en', 'fr', 'es']).default('en'), | ||
publishedAt: z.date().transform((val) => new Date(val)), | ||
}) | ||
}); | ||
|
||
const withUnionSchema = defineCollection({ | ||
schema: z.discriminatedUnion('type', [ | ||
z.object({ | ||
type: z.literal('post'), | ||
title: z.string(), | ||
description: z.string(), | ||
}), | ||
z.object({ | ||
type: z.literal('newsletter'), | ||
subject: z.string(), | ||
}), | ||
]), | ||
}); | ||
|
||
export const collections = { | ||
'with-custom-slugs': withCustomSlugs, | ||
'with-schema-config': withSchemaConfig, | ||
'with-union-schema': withUnionSchema, | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/astro/test/fixtures/content with spaces in folder name/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>It's content time!</title> | ||
<style> | ||
html, | ||
body { | ||
font-family: system-ui; | ||
margin: 0; | ||
} | ||
body { | ||
padding: 2rem; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<main> | ||
</main> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.