chore: clarify Markdoc config
This commit is contained in:
parent
9bb1c29e98
commit
8e14143984
1 changed files with 13 additions and 10 deletions
|
@ -90,7 +90,7 @@ Once the Markdoc integration is installed, no configuration is necessary to use
|
||||||
|
|
||||||
The Markdoc integration accepts [all Markdoc configuration options](https://markdoc.dev/docs/config), including [tags](https://markdoc.dev/docs/tags) and [variables](https://markdoc.dev/docs/variables).
|
The Markdoc integration accepts [all Markdoc configuration options](https://markdoc.dev/docs/config), including [tags](https://markdoc.dev/docs/tags) and [variables](https://markdoc.dev/docs/variables).
|
||||||
|
|
||||||
You can pass these options from the `markdoc()` integration in your `astro.config`. This example declares a `version` variable and an `aside` tag for use across all Markdoc Content Collection entries:
|
You can pass these options from the `markdoc()` integration in your `astro.config`. This example declares a `countries` variable and an `includes` function for use across all Markdoc Content Collection entries:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// astro.config.mjs
|
// astro.config.mjs
|
||||||
|
@ -102,16 +102,17 @@ export default defineConfig({
|
||||||
integrations: [
|
integrations: [
|
||||||
markdoc({
|
markdoc({
|
||||||
variables: {
|
variables: {
|
||||||
version: '0.0.1',
|
// Declare a global list of countries
|
||||||
|
// Usage in Markdoc: `$countries`
|
||||||
|
countries: ['EN', 'ES', 'JP'],
|
||||||
},
|
},
|
||||||
tags: {
|
functions: {
|
||||||
aside: {
|
// Check if array includes value
|
||||||
// See "Content `components` prop section
|
// Usage in Markdoc: `includes(arr, value)`
|
||||||
// for more on rendering components via tags
|
includes: {
|
||||||
render: 'Aside',
|
transform(parameters) {
|
||||||
attributes: {
|
const [array, value] = Object.values(parameters);
|
||||||
type: { type: String },
|
return array.includes(value);
|
||||||
title: { type: String },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -120,6 +121,8 @@ export default defineConfig({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
📚 [See the Markdoc documentation](https://markdoc.dev/docs/functions#creating-a-custom-function) for more on using variables or functions in your content.
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
These options will be applied during [the Markdoc "transform" phase](https://markdoc.dev/docs/render#transform). This is run **at build time** (rather than server request time) both for static and SSR Astro projects.
|
These options will be applied during [the Markdoc "transform" phase](https://markdoc.dev/docs/render#transform). This is run **at build time** (rather than server request time) both for static and SSR Astro projects.
|
||||||
::
|
::
|
||||||
|
|
Loading…
Add table
Reference in a new issue