Skip to content

Commit fff62f3

Browse files
committed
use partial in docs
1 parent 4416673 commit fff62f3

File tree

8 files changed

+326
-311
lines changed

8 files changed

+326
-311
lines changed

docs/default-theme-config/README.md

Lines changed: 6 additions & 311 deletions
Original file line numberDiff line numberDiff line change
@@ -8,323 +8,18 @@ sidebar: auto
88
All options listed on this page apply to the default theme only. If you are using a custom theme, the options may be different.
99
:::
1010

11-
## Homepage
11+
<!-- include ./partials/homepage.md -->
1212

13-
The default theme provides a homepage layout (which is used on [the homepage of this very website](/)). To use it, specify `home: true` plus some other metadata in your root `README.md`'s [YAML front matter](../guide/markdown.html#yaml-front-matter). This is the actual data used on this site:
13+
<!-- include ./partials/navbar-links.md -->
1414

15-
``` yaml
16-
---
17-
home: true
18-
heroImage: /hero.png
19-
actionText: Get Started →
20-
actionLink: /guide/
21-
features:
22-
- title: Simplicity First
23-
details: Minimal setup with markdown-centered project structure helps you focus on writing.
24-
- title: Vue-Powered
25-
details: Enjoy the dev experience of Vue + webpack, use Vue components in markdown, and develop custom themes with Vue.
26-
- title: Performant
27-
details: VuePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.
28-
footer: MIT Licensed | Copyright © 2018-present Evan You
29-
---
30-
```
31-
32-
Any additional content after the `YAML front matter` will be parsed as normal markdown and rendered after the features section.
33-
34-
If you want to use a completely custom homepage layout, you can also use a [Custom Layout](#custom-layout-for-specific-pages).
35-
36-
## Navbar Links
37-
38-
You can add links to the navbar via `themeConfig.nav`:
39-
40-
``` js
41-
// .vuepress/config.js
42-
module.exports = {
43-
themeConfig: {
44-
nav: [
45-
{ text: 'Home', link: '/' },
46-
{ text: 'Guide', link: '/guide/' },
47-
{ text: 'External', link: 'https://google.com' },
48-
]
49-
}
50-
}
51-
```
52-
53-
These links can also be dropdown menus if you provide an array of `items` instead of a `link`:
54-
55-
```js
56-
module.exports = {
57-
themeConfig: {
58-
nav: [
59-
{
60-
text: 'Languages',
61-
items: [
62-
{ text: 'Chinese', link: '/language/chinese' },
63-
{ text: 'Japanese', link: '/language/japanese' }
64-
]
65-
}
66-
]
67-
}
68-
}
69-
```
70-
71-
In addition, you can have sub groups inside a dropdown by having nested items:
72-
73-
```js
74-
module.exports = {
75-
themeConfig: {
76-
nav: [
77-
{
78-
text: 'Languages',
79-
items: [
80-
{ text: 'Group1', items: [/* */] },
81-
{ text: 'Group2', items: [/* */] }
82-
]
83-
}
84-
]
85-
}
86-
}
87-
```
88-
89-
## Sidebar
90-
91-
To enable the sidebar, use `themeConfig.sidebar`. The basic configuration expects an Array of links:
92-
93-
``` js
94-
// .vuepress/config.js
95-
module.exports = {
96-
themeConfig: {
97-
sidebar: [
98-
'/',
99-
'/page-a',
100-
['/page-b', 'Explicit link text']
101-
]
102-
}
103-
}
104-
```
105-
106-
You can omit the `.md` extension, and paths ending with `/` are inferred as `*/README.md`. The text for the link is automatically inferred (either from the first header in the page or explicit title in `YAML front matter`). If you wish to explicitly specify the link text, use an Array in form of `[link, text]`.
107-
108-
### Nested Header Links
109-
110-
The sidebar automatically displays links for headers in the current active page, nested under the link for the page itself. You can customize this behavior using `themeConfig.sidebarDepth`. The default depth is `1`, which extracts the `h2` headers. Setting it to `0` disables the header links, and the max value is `2` which extracts both `h2` and `h3` headers.
111-
112-
A page can also override this value in using `YAML front matter`:
113-
114-
``` md
115-
---
116-
sidebarDepth: 2
117-
---
118-
```
119-
120-
### Sidebar Groups
121-
122-
You can divide sidebar links into multiple groups by using objects:
123-
124-
``` js
125-
// .vuepress/config.js
126-
module.exports = {
127-
themeConfig: {
128-
sidebar: [
129-
{
130-
title: 'Group 1',
131-
collapsable: false,
132-
children: [
133-
'/'
134-
]
135-
},
136-
{
137-
title: 'Group 2',
138-
children: [ /* ... */ ]
139-
}
140-
]
141-
}
142-
}
143-
```
144-
145-
Sidebar groups are collapsable by default. You can force a group to be always open with `collapsable: false`.
146-
147-
### Multiple Sidebars
148-
149-
If you wish to display different sidebars for different sections of content, first organize your pages into directories for each desired section:
150-
151-
```
152-
.
153-
├─ README.md
154-
├─ contact.md
155-
├─ about.md
156-
├─ foo/
157-
│  ├─ README.md
158-
│ ├─ one.md
159-
│ └─ two.md
160-
└─ bar/
161-
├─ README.md
162-
├─ three.md
163-
└─ four.md
164-
```
165-
166-
Then, update your configuration to define your sidebar for each section.
167-
168-
``` js
169-
// .vuepress/config.js
170-
module.exports = {
171-
themeConfig: {
172-
sidebar: {
173-
'/foo/': [
174-
'', /* /foo/ */
175-
'one', /* /foo/one.html */
176-
'two' /* /foo/two.html */
177-
],
178-
179-
'/bar/': [
180-
'', /* /bar/ */
181-
'three', /* /bar/three.html */
182-
'four' /* /bar/four.html */
183-
],
184-
185-
// fallback
186-
'/': [
187-
'', /* / */
188-
'contact', /* /contact.html */
189-
'about' /* /about.html */
190-
]
191-
}
192-
}
193-
}
194-
```
195-
196-
::: warning
197-
Make sure to define the fallback configuration last.
198-
199-
VuePress checks each sidebar config from top to bottom. If the fallback configuration was first, VuePress would incorrectly match `/foo/` or `/bar/four.html` because they both start with `/`.
200-
:::
201-
202-
### Auto Sidebar for Single Pages
203-
204-
If you wish to automatically generate a sidebar that contains only the header links for the current page, you can use `YAML front matter` on that page:
15+
<!-- include ./partials/sidebar.md -->
20516

206-
``` yaml
207-
---
208-
sidebar: auto
209-
---
210-
```
211-
212-
### Disabling the Sidebar
213-
214-
You can disable the sidebar on a specific page with `YAML front matter`:
215-
216-
``` yaml
217-
---
218-
sidebar: false
219-
---
220-
```
221-
222-
## Search Box
223-
224-
### Built-in Search
225-
226-
You can disable the built-in search box with `themeConfig.search: false`, and customize how many suggestions to be shown with `themeConfig.searchMaxSuggestions`:
227-
228-
``` js
229-
module.exports = {
230-
themeConfig: {
231-
search: false,
232-
searchMaxSuggestions: 10
233-
}
234-
}
235-
```
236-
237-
### Algolia Search
238-
239-
The `themeConfig.algolia` option allows you to use [Algolia DocSearch](https://community.algolia.com/docsearch/) to replace the simple built-in search. To enable it, you need to provide at least `apiKey` and `indexName`:
240-
241-
```js
242-
module.exports = {
243-
themeConfig: {
244-
algolia: {
245-
apiKey: '<API_KEY>',
246-
indexName: '<INDEX_NAME>'
247-
}
248-
}
249-
}
250-
```
251-
252-
For more options, refer to [Algolia DocSearch's documentation](https://github.com/algolia/docsearch#docsearch-options).
253-
254-
## Prev / Next Links
255-
256-
Prev and next links are automatically inferred based on the sidebar order of the active page. You can also explicitly overwrite or disable them using `YAML front matter`:
17+
<!-- include ./partials/search-box.md -->
25718

258-
``` yaml
259-
---
260-
prev: ./some-other-page
261-
next: false
262-
---
263-
```
264-
265-
## Git Repo and Edit Links
266-
267-
Providing `themeConfig.repo` auto generates a GitHub link in the navbar and "Edit this page" links at the bottom of each page.
268-
269-
``` js
270-
// .vuepress/config.js
271-
module.exports = {
272-
themeConfig: {
273-
// Assumes GitHub. Can also be a full GitLab url.
274-
repo: 'vuejs/vuepress',
275-
// Customising the header label
276-
// Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on `themeConfig.repo`
277-
repoLabel: 'Contribute!',
278-
279-
// Optional options for generating "Edit this page" link
280-
281-
// if your docs are in a different repo from your main project:
282-
docsRepo: 'vuejs/vuepress',
283-
// if your docs are not at the root of the repo:
284-
docsDir: 'docs',
285-
// if your docs are in a specific branch (defaults to 'master'):
286-
docsBranch: 'master',
287-
// defaults to true, set to false to disable
288-
editLinks: true,
289-
// custom text for edit link. Defaults to "Edit this page"
290-
editLinkText: 'Help us improve this page!'
291-
}
292-
}
293-
```
294-
295-
## Simple CSS Override
296-
297-
If you wish to apply simple overrides to the styling of the default theme, you can create an `.vuepress/override.styl` file. This is a [Stylus](http://stylus-lang.com/) file but you can use normal CSS syntax as well.
19+
<!-- include ./partials/simple-css-override.md -->
29820

299-
There are a few color variables you can tweak:
21+
<!-- include ./partials/custom-page-class.md -->
30022

301-
``` stylus
302-
// showing default values
303-
$accentColor = #3eaf7c
304-
$textColor = #2c3e50
305-
$borderColor = #eaecef
306-
$codeBgColor = #282c34
307-
```
308-
309-
## Custom Page Class
310-
311-
Sometimes, you may need to add a unique class for a specific page so that you can target content on that page only in custom CSS. You can add a class to the theme container div with `pageClass` in `YAML front matter`:
312-
313-
``` yaml
314-
---
315-
pageClass: custom-page-class
316-
---
317-
```
318-
319-
Then you can write CSS targeting that page only:
320-
321-
``` css
322-
/* .vuepress/override.styl */
323-
324-
.theme-container.custom-page-class {
325-
/* page-specific rules */
326-
}
327-
```
32823

32924
## Custom Layout for Specific Pages
33025

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Custom Page Class
2+
3+
Sometimes, you may need to add a unique class for a specific page so that you can target content on that page only in custom CSS. You can add a class to the theme container div with `pageClass` in `YAML front matter`:
4+
5+
``` yaml
6+
---
7+
pageClass: custom-page-class
8+
---
9+
```
10+
11+
Then you can write CSS targeting that page only:
12+
13+
``` css
14+
/* .vuepress/override.styl */
15+
16+
.theme-container.custom-page-class {
17+
/* page-specific rules */
18+
}
19+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Homepage
2+
3+
The default theme provides a homepage layout (which is used on [the homepage of this very website](/)). To use it, specify `home: true` plus some other metadata in your root `README.md`'s [YAML front matter](../guide/markdown.html#yaml-front-matter). This is the actual data used on this site:
4+
5+
``` yaml
6+
---
7+
home: true
8+
heroImage: /hero.png
9+
actionText: Get Started →
10+
actionLink: /guide/
11+
features:
12+
- title: Simplicity First
13+
details: Minimal setup with markdown-centered project structure helps you focus on writing.
14+
- title: Vue-Powered
15+
details: Enjoy the dev experience of Vue + webpack, use Vue components in markdown, and develop custom themes with Vue.
16+
- title: Performant
17+
details: VuePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.
18+
footer: MIT Licensed | Copyright © 2018-present Evan You
19+
---
20+
```
21+
22+
Any additional content after the `YAML front matter` will be parsed as normal markdown and rendered after the features section.
23+
24+
If you want to use a completely custom homepage layout, you can also use a [Custom Layout](#custom-layout-for-specific-pages).

0 commit comments

Comments
 (0)