-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Showing
7 changed files
with
126 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Global Computed | ||
|
||
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. | ||
|
||
## $site | ||
|
||
This is the `$site` value of the site you're currently reading: | ||
|
||
```js | ||
{ | ||
base: '/', | ||
lang: 'en-US', | ||
title: 'VitePress', | ||
description: 'Vite & Vue powered static site generator.', | ||
head: [], | ||
locales: {}, | ||
themeConfig: $themeConfig | ||
} | ||
``` | ||
|
||
## $themeConfig | ||
|
||
Refers to `$site.themeConfig`. | ||
|
||
```js | ||
{ | ||
locales: {}, | ||
repo: 'vuejs/vitepress', | ||
docsDir: 'docs', | ||
editLinks: true, | ||
editLinkText: 'Edit this page on GitHub', | ||
lastUpdated: 'Last Updated', | ||
nav: [...], | ||
sidebar: { ... } | ||
} | ||
``` | ||
|
||
## $page | ||
|
||
This is the `$page` value of the page you're currently reading: | ||
|
||
```js | ||
{ | ||
relativePath: 'guide/global-computed.md', | ||
title: 'Global Computed', | ||
headers: [ | ||
{ level: 2, title: '$site', slug: 'site' }, | ||
{ level: 2, title: '$page', slug: '$page' }, | ||
... | ||
], | ||
frontmatter: $frontmatter, | ||
lastUpdated: 1606297645000 | ||
} | ||
``` | ||
|
||
## $frontmatter | ||
|
||
Reference of `$page.frontmatter`. | ||
|
||
```js | ||
{ | ||
title: 'Docs with VitePress', | ||
editLink: true | ||
} | ||
``` | ||
|
||
## $title | ||
|
||
Value of the `<title>` label used for the current page. | ||
|
||
## $description | ||
|
||
The content value of the `<meta name= "description" content= "...">` for the current page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters