Any markdown file that contains a YAML front matter block will be processed by gray-matter. The front matter must be the first thing in the markdown file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:
---
-title: Blogging Like a Hacker
-lang: en-US
----
-
Between these triple-dashed lines, you can set predefined variables (see below for a reference), or even create custom ones of your own. These variables will then be available to you to access using $frontmatter at the rest of the page, plus all custom and theming components.
::: tip
-Front matter variables are optional in VuePress.
-:::
Any markdown file that contains a YAML front matter block will be processed by gray-matter. The front matter must be the first thing in the markdown file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:
---
-title: Blogging Like a Hacker
-lang: en-US
----
-
Between these triple-dashed lines, you can set predefined variables (see below for a reference), or even create custom ones of your own. These variables will then be available to you to access using $frontmatter at the rest of the page, plus all custom and theming components.
::: tip
-Front matter variables are optional in VuePress.
-:::
Any markdown file that contains a YAML front matter block will be processed by gray-matter. The front matter must be the first thing in the markdown file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:
---
-title: Blogging Like a Hacker
-lang: en-US
----
-
Between these triple-dashed lines, you can set predefined variables (see below for a reference), or even create custom ones of your own. These variables will then be available to you to access using $frontmatter at the rest of the page, plus all custom and theming components.
::: tip
-Front matter variables are optional in VuePress.
-:::
VuePress implements a content distribution API for Markdown. With this feature, you can split your document into multiple fragments to facilitate flexible composition in the layout component.
First, let's review the relationship between layout components and markdown files:
Markdown files are providers of metadata (Page content, Configuration, etc.), while layout components consume them. We can use frontmatter to define some metadata for common data types, but frontmatter is hard to do something about markdown / HTML, a complex metadata that involves differences before and after compilation.
By default, the slot-free part of a markdown file becomes the default content of a markdown slot, which you can access directly using the Content component:
VuePress implements a content distribution API for Markdown. With this feature, you can split your document into multiple fragments to facilitate flexible composition in the layout component.
First, let's review the relationship between layout components and markdown files:
Markdown files are providers of metadata (Page content, Configuration, etc.), while layout components consume them. We can use frontmatter to define some metadata for common data types, but frontmatter is hard to do something about markdown / HTML, a complex metadata that involves differences before and after compilation.
By default, the slot-free part of a markdown file becomes the default content of a markdown slot, which you can access directly using the Content component:
VuePress implements a content distribution API for Markdown. With this feature, you can split your document into multiple fragments to facilitate flexible composition in the layout component.
First, let's review the relationship between layout components and markdown files:
Markdown files are providers of metadata (Page content, Configuration, etc.), while layout components consume them. We can use frontmatter to define some metadata for common data types, but frontmatter is hard to do something about markdown / HTML, a complex metadata that involves differences before and after compilation.
By default, the slot-free part of a markdown file becomes the default content of a markdown slot, which you can access directly using the Content component:
VuePress implements a content distribution API for Markdown. With this feature, you can split your document into multiple fragments to facilitate flexible composition in the layout component.
First, let's review the relationship between layout components and markdown files:
Markdown files are providers of metadata (Page content, Configuration, etc.), while layout components consume them. We can use frontmatter to define some metadata for common data types, but frontmatter is hard to do something about markdown / HTML, a complex metadata that involves differences before and after compilation.
By default, the slot-free part of a markdown file becomes the default content of a markdown slot, which you can access directly using the Content component:
The compiled content of the current .md file being rendered will be available as a special <Content/> global component. You will need to render it somewhere in your layout in order to display the content of the page. The simplest theme can be just a single Layout.vue component with the following content:
Just one Layout.vue might not be enough, and you might also want to define more layout components in the theme for using on different pages. You may also want to customize the palette, and even apply some plugins.
So it's time to reorganize your theme, an agreed theme directory structure is as follows:
theme/global-components: Components under this directory will be automatically registered as global components. For details, please refer to @vuepress/plugin-register-components.
theme/components: Your components.
theme/layouts: Layout components of the theme, where Layout.vue is required.
theme/styles: Global style and palette.
theme/templates: Modify default template.
theme/index.js: Entry file of theme configuration.
theme/enhanceApp.js: Theme level enhancements.
::: warning Note
-When you publish your theme as an NPM package, if you don't have any theme configuration, that means you don't have theme/index.js, you'll need to set the "main" field to layouts/Layout.vue in package.json, only in this way VuePress can correctly resolve the theme.
The Layout component will be invoked once for every .md file in docs, and the metadata for the entire site and that specific page will be exposed respectively as this.$site and this.$page properties which are injected into every component in the app.
title, description and base are copied from respective fields in .vuepress/config.js. pages contains an array of metadata objects for each page, including its path, page title (explicitly specified in YAML front matter or inferred from the first header on the page), and any YAML front matter data in that file.
This is the $page object for this page you are looking at:
If the user provided themeConfig in .vuepress/config.js, it will also be available as $site.themeConfig. You can use this to allow users to customize behavior of your theme - for example, specifying categories and page order. You can then use these data together with $site.pages to dynamically construct navigation links.
Finally, don't forget that this.$route and this.$router are also available as part of Vue Router's API.
::: tip
-lastUpdated is the UNIX timestamp of this file's last git commit, for more details, refer to Last Updated.
-:::
If a markdown file contains a <!-- more --> comment, any content above the comment will be extracted and exposed as $page.excerpt. If you are building custom theme for blogging, this data can be used to render a post list with excerpts.
Themes can enhance the Vue app that VuePress uses by exposing an enhanceApp.js file at the root of the theme. The file should export default a hook function which will receive an object containing some app-level values. You can use this hook to install additional Vue plugins, register global components, or add additional router hooks:
exportdefault({
- Vue,// the version of Vue being used in the VuePress app
- options,// the options for the root Vue instance
- router,// the router instance for the app
- siteData // site metadata
-})=>{
- // ...apply enhancements to the app
-}
-
The compiled content of the current .md file being rendered will be available as a special <Content/> global component. You will need to render it somewhere in your layout in order to display the content of the page. The simplest theme can be just a single Layout.vue component with the following content:
Just one Layout.vue might not be enough, and you might also want to define more layout components in the theme for using on different pages. You may also want to customize the palette, and even apply some plugins.
So it's time to reorganize your theme, an agreed theme directory structure is as follows:
theme/global-components: Components under this directory will be automatically registered as global components. For details, please refer to @vuepress/plugin-register-components.
theme/components: Your components.
theme/layouts: Layout components of the theme, where Layout.vue is required.
theme/styles: Global style and palette.
theme/templates: Modify default template.
theme/index.js: Entry file of theme configuration.
theme/enhanceApp.js: Theme level enhancements.
::: warning Note
-When you publish your theme as an NPM package, if you don't have any theme configuration, that means you don't have theme/index.js, you'll need to set the "main" field to layouts/Layout.vue in package.json, only in this way VuePress can correctly resolve the theme.
The Layout component will be invoked once for every .md file in docs, and the metadata for the entire site and that specific page will be exposed respectively as this.$site and this.$page properties which are injected into every component in the app.
title, description and base are copied from respective fields in .vuepress/config.js. pages contains an array of metadata objects for each page, including its path, page title (explicitly specified in YAML front matter or inferred from the first header on the page), and any YAML front matter data in that file.
This is the $page object for this page you are looking at:
If the user provided themeConfig in .vuepress/config.js, it will also be available as $site.themeConfig. You can use this to allow users to customize behavior of your theme - for example, specifying categories and page order. You can then use these data together with $site.pages to dynamically construct navigation links.
Finally, don't forget that this.$route and this.$router are also available as part of Vue Router's API.
::: tip
-lastUpdated is the UNIX timestamp of this file's last git commit, for more details, refer to Last Updated.
-:::
If a markdown file contains a <!-- more --> comment, any content above the comment will be extracted and exposed as $page.excerpt. If you are building custom theme for blogging, this data can be used to render a post list with excerpts.
Themes can enhance the Vue app that VuePress uses by exposing an enhanceApp.js file at the root of the theme. The file should export default a hook function which will receive an object containing some app-level values. You can use this hook to install additional Vue plugins, register global components, or add additional router hooks:
exportdefault({
- Vue,// the version of Vue being used in the VuePress app
- options,// the options for the root Vue instance
- router,// the router instance for the app
- siteData // site metadata
-})=>{
- // ...apply enhancements to the app
-}
-
The compiled content of the current .md file being rendered will be available as a special <Content/> global component. You will need to render it somewhere in your layout in order to display the content of the page. The simplest theme can be just a single Layout.vue component with the following content:
Just one Layout.vue might not be enough, and you might also want to define more layout components in the theme for using on different pages. You may also want to customize the palette, and even apply some plugins.
So it's time to reorganize your theme, an agreed theme directory structure is as follows:
theme/global-components: Components under this directory will be automatically registered as global components. For details, please refer to @vuepress/plugin-register-components.
theme/components: Your components.
theme/layouts: Layout components of the theme, where Layout.vue is required.
theme/styles: Global style and palette.
theme/templates: Modify default template.
theme/index.js: Entry file of theme configuration.
theme/enhanceApp.js: Theme level enhancements.
::: warning Note
-When you publish your theme as an NPM package, if you don't have any theme configuration, that means you don't have theme/index.js, you'll need to set the "main" field to layouts/Layout.vue in package.json, only in this way VuePress can correctly resolve the theme.
The Layout component will be invoked once for every .md file in docs, and the metadata for the entire site and that specific page will be exposed respectively as this.$site and this.$page properties which are injected into every component in the app.
title, description and base are copied from respective fields in .vuepress/config.js. pages contains an array of metadata objects for each page, including its path, page title (explicitly specified in YAML front matter or inferred from the first header on the page), and any YAML front matter data in that file.
This is the $page object for this page you are looking at:
If the user provided themeConfig in .vuepress/config.js, it will also be available as $site.themeConfig. You can use this to allow users to customize behavior of your theme - for example, specifying categories and page order. You can then use these data together with $site.pages to dynamically construct navigation links.
Finally, don't forget that this.$route and this.$router are also available as part of Vue Router's API.
::: tip
-lastUpdated is the UNIX timestamp of this file's last git commit, for more details, refer to Last Updated.
-:::
If a markdown file contains a <!-- more --> comment, any content above the comment will be extracted and exposed as $page.excerpt. If you are building custom theme for blogging, this data can be used to render a post list with excerpts.
Themes can enhance the Vue app that VuePress uses by exposing an enhanceApp.js file at the root of the theme. The file should export default a hook function which will receive an object containing some app-level values. You can use this hook to install additional Vue plugins, register global components, or add additional router hooks:
exportdefault({
- Vue,// the version of Vue being used in the VuePress app
- options,// the options for the root Vue instance
- router,// the router instance for the app
- siteData // site metadata
-})=>{
- // ...apply enhancements to the app
-}
-
The compiled content of the current .md file being rendered will be available as a special <Content/> global component. You will need to render it somewhere in your layout in order to display the content of the page. The simplest theme can be just a single Layout.vue component with the following content:
Just one Layout.vue might not be enough, and you might also want to define more layout components in the theme for using on different pages. You may also want to customize the palette, and even apply some plugins.
So it's time to reorganize your theme, an agreed theme directory structure is as follows:
theme/global-components: Components under this directory will be automatically registered as global components. For details, please refer to @vuepress/plugin-register-components.
theme/components: Your components.
theme/layouts: Layout components of the theme, where Layout.vue is required.
theme/styles: Global style and palette.
theme/templates: Modify default template.
theme/index.js: Entry file of theme configuration.
theme/enhanceApp.js: Theme level enhancements.
::: warning Note
-When you publish your theme as an NPM package, if you don't have any theme configuration, that means you don't have theme/index.js, you'll need to set the "main" field to layouts/Layout.vue in package.json, only in this way VuePress can correctly resolve the theme.
The Layout component will be invoked once for every .md file in docs, and the metadata for the entire site and that specific page will be exposed respectively as this.$site and this.$page properties which are injected into every component in the app.
title, description and base are copied from respective fields in .vuepress/config.js. pages contains an array of metadata objects for each page, including its path, page title (explicitly specified in YAML front matter or inferred from the first header on the page), and any YAML front matter data in that file.
This is the $page object for this page you are looking at:
If the user provided themeConfig in .vuepress/config.js, it will also be available as $site.themeConfig. You can use this to allow users to customize behavior of your theme - for example, specifying categories and page order. You can then use these data together with $site.pages to dynamically construct navigation links.
Finally, don't forget that this.$route and this.$router are also available as part of Vue Router's API.
::: tip
-lastUpdated is the UNIX timestamp of this file's last git commit, for more details, refer to Last Updated.
-:::
If a markdown file contains a <!-- more --> comment, any content above the comment will be extracted and exposed as $page.excerpt. If you are building custom theme for blogging, this data can be used to render a post list with excerpts.
Themes can enhance the Vue app that VuePress uses by exposing an enhanceApp.js file at the root of the theme. The file should export default a hook function which will receive an object containing some app-level values. You can use this hook to install additional Vue plugins, register global components, or add additional router hooks:
exportdefault({
- Vue,// the version of Vue being used in the VuePress app
- options,// the options for the root Vue instance
- router,// the router instance for the app
- siteData // site metadata
-})=>{
- // ...apply enhancements to the app
-}
-