mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
466 lines
9.9 KiB
466 lines
9.9 KiB
2 years ago
|
# Default Theme Config
|
||
3 years ago
|
|
||
2 years ago
|
Theme config lets you customize your theme. You can define theme config via the `themeConfig` option in the config file:
|
||
3 years ago
|
|
||
|
```ts
|
||
|
export default {
|
||
|
lang: 'en-US',
|
||
|
title: 'VitePress',
|
||
|
description: 'Vite & Vue powered static site generator.',
|
||
|
|
||
|
// Theme related configurations.
|
||
|
themeConfig: {
|
||
|
logo: '/logo.svg',
|
||
|
nav: [...],
|
||
|
sidebar: { ... }
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
2 years ago
|
**The options documented on this page only apply to the default theme.** Different themes expect different theme config. When using a custom theme, the theme config object will be passed to the theme so the theme can define conditional behavior based on it.
|
||
3 years ago
|
|
||
2 years ago
|
## i18nRouting
|
||
|
|
||
|
- Type: `boolean`
|
||
|
|
||
|
Changing locale to say `zh` will change the URL from `/foo` (or `/en/foo/`) to `/zh/foo`. You can disable this behavior by setting `themeConfig.i18nRouting` to `false`.
|
||
|
|
||
3 years ago
|
## logo
|
||
|
|
||
2 years ago
|
- Type: `ThemeableImage`
|
||
3 years ago
|
|
||
2 years ago
|
Logo file to display in nav bar, right before the site title. Accepts a path string, or an object to set a different logo for light/dark mode.
|
||
3 years ago
|
|
||
|
```ts
|
||
|
export default {
|
||
|
themeConfig: {
|
||
|
logo: '/logo.svg'
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
2 years ago
|
```ts
|
||
2 years ago
|
type ThemeableImage =
|
||
|
| string
|
||
|
| { src: string; alt?: string }
|
||
|
| { light: string; dark: string; alt?: string }
|
||
2 years ago
|
```
|
||
|
|
||
3 years ago
|
## siteTitle
|
||
|
|
||
|
- Type: `string | false`
|
||
|
|
||
|
You can customize this item to replace the default site title (`title` in app config) in nav. When set to `false`, title in nav will be disabled. Useful when you have `logo` that already contains the site title text.
|
||
|
|
||
|
```ts
|
||
|
export default {
|
||
|
themeConfig: {
|
||
|
siteTitle: 'Hello World'
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
3 years ago
|
## nav
|
||
|
|
||
|
- Type: `NavItem`
|
||
|
|
||
2 years ago
|
The configuration for the nav menu item. More details in [Default Theme: Nav](./default-theme-nav#navigation-links).
|
||
3 years ago
|
|
||
1 year ago
|
```ts
|
||
3 years ago
|
export default {
|
||
|
themeConfig: {
|
||
|
nav: [
|
||
|
{ text: 'Guide', link: '/guide' },
|
||
|
{
|
||
|
text: 'Dropdown Menu',
|
||
|
items: [
|
||
|
{ text: 'Item A', link: '/item-1' },
|
||
|
{ text: 'Item B', link: '/item-2' },
|
||
|
{ text: 'Item C', link: '/item-3' }
|
||
|
]
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
type NavItem = NavItemWithLink | NavItemWithChildren
|
||
|
|
||
2 years ago
|
interface NavItemWithLink {
|
||
3 years ago
|
text: string
|
||
|
link: string
|
||
|
activeMatch?: string
|
||
2 years ago
|
target?: string
|
||
|
rel?: string
|
||
9 months ago
|
noIcon?: boolean
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
interface NavItemChildren {
|
||
3 years ago
|
text?: string
|
||
|
items: NavItemWithLink[]
|
||
2 years ago
|
}
|
||
|
|
||
|
interface NavItemWithChildren {
|
||
|
text?: string
|
||
|
items: (NavItemChildren | NavItemWithLink)[]
|
||
2 years ago
|
activeMatch?: string
|
||
3 years ago
|
}
|
||
|
```
|
||
|
|
||
|
## sidebar
|
||
|
|
||
|
- Type: `Sidebar`
|
||
|
|
||
2 years ago
|
The configuration for the sidebar menu item. More details in [Default Theme: Sidebar](./default-theme-sidebar).
|
||
3 years ago
|
|
||
1 year ago
|
```ts
|
||
3 years ago
|
export default {
|
||
|
themeConfig: {
|
||
|
sidebar: [
|
||
|
{
|
||
|
text: 'Guide',
|
||
|
items: [
|
||
|
{ text: 'Introduction', link: '/introduction' },
|
||
|
{ text: 'Getting Started', link: '/getting-started' },
|
||
|
...
|
||
|
]
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```ts
|
||
2 years ago
|
export type Sidebar = SidebarItem[] | SidebarMulti
|
||
3 years ago
|
|
||
2 years ago
|
export interface SidebarMulti {
|
||
8 months ago
|
[path: string]: SidebarItem[] | { items: SidebarItem[]; base: string }
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
export type SidebarItem = {
|
||
|
/**
|
||
|
* The text label of the item.
|
||
|
*/
|
||
|
text?: string
|
||
|
|
||
|
/**
|
||
|
* The link of the item.
|
||
|
*/
|
||
|
link?: string
|
||
|
|
||
|
/**
|
||
|
* The children of the item.
|
||
|
*/
|
||
|
items?: SidebarItem[]
|
||
|
|
||
|
/**
|
||
2 years ago
|
* If not specified, group is not collapsible.
|
||
2 years ago
|
*
|
||
2 years ago
|
* If `true`, group is collapsible and collapsed by default
|
||
2 years ago
|
*
|
||
2 years ago
|
* If `false`, group is collapsible but expanded by default
|
||
2 years ago
|
*/
|
||
|
collapsed?: boolean
|
||
8 months ago
|
|
||
|
/**
|
||
|
* Base path for the children items.
|
||
|
*/
|
||
|
base?: string
|
||
|
|
||
|
/**
|
||
|
* Customize text that appears on the footer of previous/next page.
|
||
|
*/
|
||
|
docFooterText?: string
|
||
|
|
||
|
rel?: string
|
||
|
target?: string
|
||
3 years ago
|
}
|
||
|
```
|
||
|
|
||
2 years ago
|
## aside
|
||
|
|
||
2 years ago
|
- Type: `boolean | 'left'`
|
||
2 years ago
|
- Default: `true`
|
||
2 years ago
|
- Can be overridden per page via [frontmatter](./frontmatter-config#aside)
|
||
2 years ago
|
|
||
2 years ago
|
Setting this value to `false` prevents rendering of aside container.\
|
||
|
Setting this value to `true` renders the aside to the right.\
|
||
|
Setting this value to `left` renders the aside to the left.
|
||
2 years ago
|
|
||
1 year ago
|
If you want to disable it for all viewports, you should use `outline: false` instead.
|
||
2 years ago
|
|
||
1 year ago
|
## outline
|
||
2 years ago
|
|
||
1 year ago
|
- Type: `Outline | Outline['level'] | false`
|
||
|
- Level can be overridden per page via [frontmatter](./frontmatter-config#outline)
|
||
2 years ago
|
|
||
1 year ago
|
Setting this value to `false` prevents rendering of outline container. Refer this interface for more details:
|
||
2 years ago
|
|
||
1 year ago
|
```ts
|
||
|
interface Outline {
|
||
|
/**
|
||
|
* The levels of headings to be displayed in the outline.
|
||
|
* Single number means only headings of that level will be displayed.
|
||
|
* If a tuple is passed, the first number is the minimum level and the second number is the maximum level.
|
||
|
* `'deep'` is same as `[2, 6]`, which means all headings from `<h2>` to `<h6>` will be displayed.
|
||
|
*
|
||
|
* @default 2
|
||
|
*/
|
||
|
level?: number | [number, number] | 'deep'
|
||
2 years ago
|
|
||
1 year ago
|
/**
|
||
|
* The title to be displayed on the outline.
|
||
|
*
|
||
|
* @default 'On this page'
|
||
|
*/
|
||
|
label?: string
|
||
2 years ago
|
}
|
||
|
```
|
||
|
|
||
3 years ago
|
## socialLinks
|
||
|
|
||
2 years ago
|
- Type: `SocialLink[]`
|
||
3 years ago
|
|
||
|
You may define this option to show your social account links with icons in nav.
|
||
|
|
||
1 year ago
|
```ts
|
||
3 years ago
|
export default {
|
||
|
themeConfig: {
|
||
|
socialLinks: [
|
||
|
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' },
|
||
|
{ icon: 'twitter', link: '...' },
|
||
2 years ago
|
// You can also add custom icons by passing SVG as string:
|
||
|
{
|
||
|
icon: {
|
||
|
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Dribbble</title><path d="M12...6.38z"/></svg>'
|
||
|
},
|
||
2 years ago
|
link: '...',
|
||
|
// You can include a custom label for accessibility too (optional but recommended):
|
||
|
ariaLabel: 'cool link'
|
||
2 years ago
|
}
|
||
3 years ago
|
]
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
interface SocialLink {
|
||
|
icon: SocialLinkIcon
|
||
|
link: string
|
||
2 years ago
|
ariaLabel?: string
|
||
3 years ago
|
}
|
||
|
|
||
|
type SocialLinkIcon =
|
||
|
| 'discord'
|
||
|
| 'facebook'
|
||
|
| 'github'
|
||
|
| 'instagram'
|
||
|
| 'linkedin'
|
||
2 years ago
|
| 'mastodon'
|
||
11 months ago
|
| 'npm'
|
||
3 years ago
|
| 'slack'
|
||
|
| 'twitter'
|
||
11 months ago
|
| 'x'
|
||
3 years ago
|
| 'youtube'
|
||
2 years ago
|
| { svg: string }
|
||
3 years ago
|
```
|
||
|
|
||
3 years ago
|
## footer
|
||
|
|
||
|
- Type: `Footer`
|
||
1 year ago
|
- Can be overridden per page via [frontmatter](./frontmatter-config#footer)
|
||
3 years ago
|
|
||
2 years ago
|
Footer configuration. You can add a message or copyright text on the footer, however, it will only be displayed when the page doesn't contain a sidebar. This is due to design concerns.
|
||
3 years ago
|
|
||
|
```ts
|
||
|
export default {
|
||
|
themeConfig: {
|
||
|
footer: {
|
||
|
message: 'Released under the MIT License.',
|
||
|
copyright: 'Copyright © 2019-present Evan You'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
export interface Footer {
|
||
|
message?: string
|
||
|
copyright?: string
|
||
|
}
|
||
|
```
|
||
3 years ago
|
|
||
3 years ago
|
## editLink
|
||
|
|
||
|
- Type: `EditLink`
|
||
2 years ago
|
- Can be overridden per page via [frontmatter](./frontmatter-config#editlink)
|
||
3 years ago
|
|
||
2 years ago
|
Edit Link lets you display a link to edit the page on Git management services such as GitHub, or GitLab. See [Default Theme: Edit Link](./default-theme-edit-link) for more details.
|
||
3 years ago
|
|
||
1 year ago
|
```ts
|
||
3 years ago
|
export default {
|
||
|
themeConfig: {
|
||
|
editLink: {
|
||
|
pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path',
|
||
|
text: 'Edit this page on GitHub'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
export interface EditLink {
|
||
|
pattern: string
|
||
|
text?: string
|
||
|
}
|
||
|
```
|
||
|
|
||
1 year ago
|
## lastUpdated
|
||
3 years ago
|
|
||
1 year ago
|
- Type: `LastUpdatedOptions`
|
||
3 years ago
|
|
||
1 year ago
|
Allows customization for the last updated text and date format.
|
||
3 years ago
|
|
||
|
```ts
|
||
|
export default {
|
||
|
themeConfig: {
|
||
1 year ago
|
lastUpdated: {
|
||
|
text: 'Updated at',
|
||
|
formatOptions: {
|
||
|
dateStyle: 'full',
|
||
|
timeStyle: 'medium'
|
||
|
}
|
||
|
}
|
||
3 years ago
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
1 year ago
|
```ts
|
||
|
export interface LastUpdatedOptions {
|
||
|
/**
|
||
|
* @default 'Last updated'
|
||
|
*/
|
||
|
text?: string
|
||
|
|
||
|
/**
|
||
|
* @default
|
||
|
* { dateStyle: 'short', timeStyle: 'short' }
|
||
|
*/
|
||
1 year ago
|
formatOptions?: Intl.DateTimeFormatOptions & { forceLocale?: boolean }
|
||
1 year ago
|
}
|
||
|
```
|
||
|
|
||
2 years ago
|
## algolia
|
||
|
|
||
|
- Type: `AlgoliaSearch`
|
||
|
|
||
2 years ago
|
An option to support searching your docs site using [Algolia DocSearch](https://docsearch.algolia.com/docs/what-is-docsearch). Learn more in [Default Theme: Search](./default-theme-search)
|
||
2 years ago
|
|
||
|
```ts
|
||
|
export interface AlgoliaSearchOptions extends DocSearchProps {
|
||
2 years ago
|
locales?: Record<string, Partial<DocSearchProps>>
|
||
2 years ago
|
}
|
||
|
```
|
||
|
|
||
|
View full options [here](https://github.com/vuejs/vitepress/blob/main/types/docsearch.d.ts).
|
||
|
|
||
2 years ago
|
## carbonAds {#carbon-ads}
|
||
3 years ago
|
|
||
2 years ago
|
- Type: `CarbonAdsOptions`
|
||
3 years ago
|
|
||
2 years ago
|
An option to display [Carbon Ads](https://www.carbonads.net/).
|
||
3 years ago
|
|
||
|
```ts
|
||
|
export default {
|
||
|
themeConfig: {
|
||
|
carbonAds: {
|
||
|
code: 'your-carbon-code',
|
||
|
placement: 'your-carbon-placement'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```ts
|
||
2 years ago
|
export interface CarbonAdsOptions {
|
||
2 years ago
|
code: string
|
||
3 years ago
|
placement: string
|
||
|
}
|
||
|
```
|
||
|
|
||
2 years ago
|
Learn more in [Default Theme: Carbon Ads](./default-theme-carbon-ads)
|
||
2 years ago
|
|
||
|
## docFooter
|
||
|
|
||
|
- Type: `DocFooter`
|
||
|
|
||
1 year ago
|
Can be used to customize text appearing above previous and next links. Helpful if not writing docs in English. Also can be used to disable prev/next links globally. If you want to selectively enable/disable prev/next links, you can use [frontmatter](./default-theme-prev-next-links).
|
||
2 years ago
|
|
||
1 year ago
|
```ts
|
||
2 years ago
|
export default {
|
||
|
themeConfig: {
|
||
|
docFooter: {
|
||
|
prev: 'Pagina prior',
|
||
|
next: 'Proxima pagina'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
export interface DocFooter {
|
||
1 year ago
|
prev?: string | false
|
||
|
next?: string | false
|
||
2 years ago
|
}
|
||
|
```
|
||
2 years ago
|
|
||
|
## darkModeSwitchLabel
|
||
|
|
||
|
- Type: `string`
|
||
|
- Default: `Appearance`
|
||
|
|
||
|
Can be used to customize the dark mode switch label. This label is only displayed in the mobile view.
|
||
|
|
||
11 months ago
|
## lightModeSwitchTitle
|
||
|
|
||
|
- Type: `string`
|
||
|
- Default: `Switch to light theme`
|
||
|
|
||
|
Can be used to customize the light mode switch title that appears on hovering.
|
||
|
|
||
|
## darkModeSwitchTitle
|
||
|
|
||
|
- Type: `string`
|
||
|
- Default: `Switch to dark theme`
|
||
|
|
||
|
Can be used to customize the dark mode switch title that appears on hovering.
|
||
|
|
||
2 years ago
|
## sidebarMenuLabel
|
||
|
|
||
|
- Type: `string`
|
||
|
- Default: `Menu`
|
||
|
|
||
|
Can be used to customize the sidebar menu label. This label is only displayed in the mobile view.
|
||
|
|
||
|
## returnToTopLabel
|
||
|
|
||
|
- Type: `string`
|
||
|
- Default: `Return to top`
|
||
|
|
||
2 years ago
|
Can be used to customize the label of the return to top button. This label is only displayed in the mobile view.
|
||
|
|
||
|
## langMenuLabel
|
||
|
|
||
|
- Type: `string`
|
||
|
- Default: `Change language`
|
||
|
|
||
|
Can be used to customize the aria-label of the language toggle button in navbar. This is only used if you're using [i18n](../guide/i18n).
|
||
1 year ago
|
|
||
|
## externalLinkIcon
|
||
|
|
||
|
- Type: `boolean`
|
||
|
- Default: `false`
|
||
|
|
||
|
Whether to show an external link icon next to external links in markdown.
|