You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: add more global and computed properties (#152)
BREAKING CHANGE: `$theme` global computed is renamed to `$themeConfig`
to align better with VuePress.
Co-authored-by: Kia King Ishii <kia.king.08@gmail.com>
Copy file name to clipboardExpand all lines: docs/guide/frontmatter.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ editLink: true
9
9
---
10
10
```
11
11
12
-
Between the triple-dashed lines, you can set [predefined variables](#predefined-variables), or even create custom ones of your own. These variables can be used via the <code>\$page.frontmatter</code> variable.
12
+
Between the triple-dashed lines, you can set [predefined variables](#predefined-variables), or even create custom ones of your own. These variables can be used via the <code>$frontmatter</code> variable.
13
13
14
14
Here’s an example of how you could use it in your Markdown file:
In VitePress, some core [computed properties](https://v3.vuejs.org/guide/computed.html#computed-properties) can be used by the default theme or custom themes. Or directly in Markdown pages using vue, for example using `$frontmatter.title` to access the title defined in the frontmatter section of the page.
4
+
5
+
## $site
6
+
7
+
This is the `$site` value of the site you're currently reading:
8
+
9
+
```js
10
+
{
11
+
base:'/',
12
+
lang:'en-US',
13
+
title:'VitePress',
14
+
description:'Vite & Vue powered static site generator.',
15
+
head: [],
16
+
locales: {},
17
+
themeConfig: $themeConfig
18
+
}
19
+
```
20
+
21
+
## $themeConfig
22
+
23
+
Refers to `$site.themeConfig`.
24
+
25
+
```js
26
+
{
27
+
locales: {},
28
+
repo:'vuejs/vitepress',
29
+
docsDir:'docs',
30
+
editLinks:true,
31
+
editLinkText:'Edit this page on GitHub',
32
+
lastUpdated:'Last Updated',
33
+
nav: [...],
34
+
sidebar: { ... }
35
+
}
36
+
```
37
+
38
+
## $page
39
+
40
+
This is the `$page` value of the page you're currently reading:
41
+
42
+
```js
43
+
{
44
+
relativePath:'guide/global-computed.md',
45
+
title:'Global Computed',
46
+
headers: [
47
+
{ level:2, title:'$site', slug:'site' },
48
+
{ level:2, title:'$page', slug:'$page' },
49
+
...
50
+
],
51
+
frontmatter: $frontmatter,
52
+
lastUpdated:1606297645000
53
+
}
54
+
```
55
+
56
+
## $frontmatter
57
+
58
+
Reference of `$page.frontmatter`.
59
+
60
+
```js
61
+
{
62
+
title:'Docs with VitePress',
63
+
editLink:true
64
+
}
65
+
```
66
+
67
+
## $title
68
+
69
+
Value of the `<title>` label used for the current page.
70
+
71
+
## $description
72
+
73
+
The content value of the `<meta name= "description" content= "...">` for the current page.
0 commit comments