summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/README.md
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2023-05-30 16:18:20 -0400
committerGravatar GitHub <noreply@github.com> 2023-05-30 16:18:20 -0400
commitbef3a75dbc48d584daff9f7f3d5a8937b0356170 (patch)
tree536921af91ee7864192369e39be6f99eed134741 /packages/integrations/markdoc/README.md
parentc7897f20a9d6e04f9cdee9a0f7e48e59adf1e59a (diff)
downloadastro-bef3a75dbc48d584daff9f7f3d5a8937b0356170.tar.gz
astro-bef3a75dbc48d584daff9f7f3d5a8937b0356170.tar.zst
astro-bef3a75dbc48d584daff9f7f3d5a8937b0356170.zip
Markdoc - remove `$entry` variable (#7244)
* refactor: remove entry prop from `getRenderModule()` * refactor: remove `$entry` from markdoc * test: update entry-prop -> variables test * refactor: unify `getEntryConfigByExt` * chore: clean up shared content / data get logic * docs: update `$entry` recommendation * chore: rename entry-prop -> variables * chore: changeset * chore: missed a spot
Diffstat (limited to 'packages/integrations/markdoc/README.md')
-rw-r--r--packages/integrations/markdoc/README.md31
1 files changed, 17 insertions, 14 deletions
diff --git a/packages/integrations/markdoc/README.md b/packages/integrations/markdoc/README.md
index 011f042ee..da5aeb46a 100644
--- a/packages/integrations/markdoc/README.md
+++ b/packages/integrations/markdoc/README.md
@@ -290,20 +290,6 @@ export default defineMarkdocConfig({
})
```
-### Access frontmatter and content collection information from your templates
-
-You can access content collection information from your Markdoc templates using the `$entry` variable. This includes the entry `slug`, `collection` name, and frontmatter `data` parsed by your content collection schema (if any). This example renders the `title` frontmatter property as a heading:
-
-```md
----
-title: Welcome to Markdoc 👋
----
-
-# {% $entry.data.title %}
-```
-
-The `$entry` object matches [the `CollectionEntry` type](https://docs.astro.build/en/reference/api-reference/#collection-entry-type), excluding the `.render()` property.
-
### Markdoc config
The `markdoc.config.mjs|ts` file accepts [all Markdoc configuration options](https://markdoc.dev/docs/config), including [tags](https://markdoc.dev/docs/tags) and [functions](https://markdoc.dev/docs/functions).
@@ -379,6 +365,23 @@ export default defineMarkdocConfig({
})
```
+### Access frontmatter from your Markdoc content
+
+To access frontmatter, you can pass the entry `data` property [as a variable](#pass-markdoc-variables) where you render your content:
+
+```astro
+---
+import { getEntry } from 'astro:content';
+
+const entry = await getEntry('docs', 'why-markdoc');
+const { Content } = await entry.render();
+---
+
+<Content frontmatter={entry.data} />
+```
+
+This can now be accessed as `$frontmatter` in your Markdoc.
+
## Examples
* The [Astro Markdoc starter template](https://github.com/withastro/astro/tree/latest/examples/with-markdoc) shows how to use Markdoc files in your Astro project.