mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
7315050fc1
This deprecated Astro.glob, see the changeset for details.
19 lines
753 B
Markdown
19 lines
753 B
Markdown
---
|
|
'astro': major
|
|
---
|
|
|
|
Deprecate Astro.glob
|
|
|
|
The `Astro.glob` function has been deprecated in favor of Content Collections and `import.meta.glob`.
|
|
|
|
- If you want to query for markdown and MDX in your project, use Content Collections.
|
|
- If you want to query source files in your project, use `import.meta.glob`(https://vitejs.dev/guide/features.html#glob-import).
|
|
|
|
Also consider using glob packages from npm, like [fast-glob](https://www.npmjs.com/package/fast-glob), especially if statically generating your site, as it is faster for most use-cases.
|
|
|
|
The easiest path is to migrate to `import.meta.glob` like so:
|
|
|
|
```diff
|
|
- const posts = Astro.glob('./posts/*.md');
|
|
+ const posts = Object.values(import.meta.glob('./posts/*.md', { eager: true }));
|
|
```
|