Skip to content

Commit

Permalink
Astro.glob(): draft:true warning
Browse files Browse the repository at this point in the history
There is a warning here: https://docs.astro.build/en/guides/markdown-content/#markdown-drafts

Seems wise to have it here as well: https://docs.astro.build/en/reference/api-reference/#astroglob

... Which is what this PR does.
  • Loading branch information
mrienstra authored Sep 13, 2022
1 parent 0b795ff commit 9ee9f64
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pages/en/reference/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const posts = await Astro.glob('../pages/post/*.md'); // returns an array of pos

`.glob()` can't take variables or strings that interpolate them, as they aren't statically analyzable. (See [the troubleshooting guide](/en/guides/troubleshooting/#supported-values) for a workaround.) This is because `Astro.glob()` is a wrapper of Vite's [`import.meta.glob()`](https://vitejs.dev/guide/features.html#glob-import).

:::caution[Astro.glob() and Markdown Drafts]
Although [`draft: true`](/en/guides/markdown-content/#markdown-drafts) will prevent a page from being built on your site at that page route, `Astro.glob()` currently returns **all your Markdown files**.
:::

:::note
You can also use `import.meta.glob()` itself in your Astro project. You may want to do this when:
- You need this feature in a file that isn't `.astro`, like an API route. `Astro.glob()` is only available in `.astro` files, while `import.meta.glob()` is available anywhere in the project.
Expand Down

0 comments on commit 9ee9f64

Please sign in to comment.