Skip to content

Commit 60198e5

Browse files
Tim Qianbencodezen
Tim Qian
andauthored
docs: add example for how to use $frontmatter variable (#2451)
* add hint for how to use variables * docs: update example for how frontmatter is used as a variable * Update packages/docs/docs/guide/frontmatter.md Co-authored-by: Ben Hong <[email protected]>
1 parent eece2e3 commit 60198e5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/docs/docs/guide/frontmatter.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ lang: en-US
99
---
1010
```
1111

12-
Between these triple-dashed lines, you can set predefined variables (see [below](#predefined-variables) for a reference), or even create custom ones of your own. These variables will then be available to you to access using <code>[$frontmatter](./global-computed.md#frontmatter)</code> at the rest of the page, plus all custom and theming components.
12+
Between these triple-dashed lines, you can set predefined variables (see [below](#predefined-variables) for a reference), or even create custom ones of your own. These variables will then be available to you through the <code>[$frontmatter](./global-computed.md#frontmatter)</code> variable.
13+
14+
Here's an example of how you could use it in your markdown file:
15+
\````
16+
---
17+
title: My Blog Title
18+
lang: English
19+
---
20+
21+
# {{ $frontmatter.title }}
22+
23+
My blog post is written in {{ $frontmatter.language }}.
24+
25+
\````
26+
27+
1328

1429
::: tip
1530
frontmatter variables are **optional** in VuePress.

0 commit comments

Comments
 (0)