mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
50a0146e9a
* feat: support pattern arrays with glob * feat: allow arrays of patterns for content layer * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
23 lines
904 B
Markdown
23 lines
904 B
Markdown
---
|
|
'astro': patch
|
|
---
|
|
|
|
Adds support for array patterns in the built-in `glob()` content collections loader
|
|
|
|
The glob loader can now accept an array of multiple patterns as well as string patterns. This allows you to more easily combine multiple patterns into a single collection, and also means you can use negative matches to exclude files from the collection.
|
|
|
|
```ts
|
|
const probes = defineCollection({
|
|
// Load all markdown files in the space-probes directory, except for those that start with "voyager-"
|
|
loader: glob({ pattern: ['*.md', '!voyager-*'], base: 'src/data/space-probes' }),
|
|
schema: z.object({
|
|
name: z.string(),
|
|
type: z.enum(['Space Probe', 'Mars Rover', 'Comet Lander']),
|
|
launch_date: z.date(),
|
|
status: z.enum(['Active', 'Inactive', 'Decommissioned']),
|
|
destination: z.string(),
|
|
operator: z.string(),
|
|
notable_discoveries: z.array(z.string()),
|
|
}),
|
|
});
|
|
```
|