mirror of https://github.com/vuejs/vitepress
commit
86744ef5b2
@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: 'bug: pending triage'
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--
|
|
||||||
NOTE:
|
|
||||||
VitePress is still WIP, and it is not compatible with VuePress.
|
|
||||||
Please do not open issue about default theme missing features or something doesn't work like VuePress.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**System Info**
|
|
||||||
- vitepress version:
|
|
||||||
- vite version:
|
|
||||||
- Node version:
|
|
||||||
- OS version:
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
@ -0,0 +1,60 @@
|
|||||||
|
name: "\U0001F41E Bug report"
|
||||||
|
description: Create a report to help us improve
|
||||||
|
labels: ['bug: pending triage']
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
"Thanks for taking the time to fill out this bug report!
|
||||||
|
VitePress is still WIP, and it is not compatible with VuePress.
|
||||||
|
Please do not open issue about default theme missing features or something doesn't work like VuePress."
|
||||||
|
- type: textarea
|
||||||
|
id: bug-description
|
||||||
|
attributes:
|
||||||
|
label: Describe the bug
|
||||||
|
description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!
|
||||||
|
placeholder: Bug description
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproduction
|
||||||
|
attributes:
|
||||||
|
label: Reproduction
|
||||||
|
description: Steps to reproduce the behavior
|
||||||
|
placeholder: Reproduction
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: expected
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: A clear and concise description of what you expected to happen.
|
||||||
|
placeholder: Expected behavior
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: system-info
|
||||||
|
attributes:
|
||||||
|
label: System Info
|
||||||
|
description: Output of `npx envinfo --system --npmPackages vitepress --binaries --browsers`
|
||||||
|
render: shell
|
||||||
|
placeholder: System, Binaries, Browsers
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: additional-context
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context or screenshots about the bug report here.
|
||||||
|
- type: checkboxes
|
||||||
|
id: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Validations
|
||||||
|
description: Before submitting the issue, please make sure you do the following
|
||||||
|
options:
|
||||||
|
- label: Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
|
||||||
|
required: true
|
||||||
|
- label: Read the [docs](https://vitepress.vuejs.org).
|
||||||
|
required: true
|
||||||
|
- label: Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
|
||||||
|
required: true
|
@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
@ -0,0 +1,45 @@
|
|||||||
|
name: "\U0001F680 New feature proposal"
|
||||||
|
description: Suggest an idea for this project
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for your interest in the project and taking the time to fill out this feature report!
|
||||||
|
- type: textarea
|
||||||
|
id: feature-description
|
||||||
|
attributes:
|
||||||
|
label: Is your feature request related to a problem? Please describe.
|
||||||
|
description: "A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: suggested-solution
|
||||||
|
attributes:
|
||||||
|
label: Describe the solution you'd like
|
||||||
|
description: A clear and concise description of what you want to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: alternative
|
||||||
|
attributes:
|
||||||
|
label: Describe alternatives you've considered
|
||||||
|
description: A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
- type: textarea
|
||||||
|
id: additional-context
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context or screenshots about the feature request here.
|
||||||
|
- type: checkboxes
|
||||||
|
id: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Validations
|
||||||
|
description: Before submitting the issue, please make sure you do the following
|
||||||
|
options:
|
||||||
|
- label: Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
|
||||||
|
required: true
|
||||||
|
- label: Read the [docs](https://vitepress.vuejs.org).
|
||||||
|
required: true
|
||||||
|
- label: Read the [Contributing Guidelines](https://github.com/vuejs/vitepress/blob/main/.github/contributing.md).
|
||||||
|
required: true
|
||||||
|
- label: Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
|
||||||
|
required: true
|
@ -0,0 +1,23 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||||
|
|
||||||
|
name: Create Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Create Release for Tag
|
||||||
|
id: release_tag
|
||||||
|
uses: yyx990803/release-tag@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
body: |
|
||||||
|
Please refer to [CHANGELOG.md](https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md) for details.
|
@ -1,11 +1,12 @@
|
|||||||
/coverage
|
/coverage
|
||||||
/src/client/shared
|
/src/client/shared.ts
|
||||||
/src/node/shared
|
/src/node/shared.ts
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.vite_opt_cache
|
.vite_opt_cache
|
||||||
dist
|
dist
|
||||||
node_modules
|
node_modules
|
||||||
TODOs.md
|
TODOs.md
|
||||||
.idea
|
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
|
pnpm-global
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"lib": ["ESNext", "DOM"],
|
||||||
|
"types": ["node", "vitest/global"],
|
||||||
|
"paths": {
|
||||||
|
"node/*": ["../src/node/*"],
|
||||||
|
"client/*": ["../src/client/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["../src", "."]
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
node: path.resolve(__dirname, '../src/node'),
|
||||||
|
client: path.resolve(__dirname, '../src/client')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||||
|
|
||||||
|
"projectFolder": "./src/client",
|
||||||
|
|
||||||
|
"mainEntryPointFilePath": "./dist/temp/index.d.ts",
|
||||||
|
|
||||||
|
"dtsRollup": {
|
||||||
|
"enabled": true,
|
||||||
|
"publicTrimmedFilePath": "./dist/client/index.d.ts"
|
||||||
|
},
|
||||||
|
|
||||||
|
"apiReport": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"docModel": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"tsdocMetadata": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"messages": {
|
||||||
|
"compilerMessageReporting": {
|
||||||
|
"default": {
|
||||||
|
"logLevel": "warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"extractorMessageReporting": {
|
||||||
|
"default": {
|
||||||
|
"logLevel": "warning",
|
||||||
|
"addToApiReportFile": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"ae-missing-release-tag": {
|
||||||
|
"logLevel": "none"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"tsdocMessageReporting": {
|
||||||
|
"default": {
|
||||||
|
"logLevel": "warning"
|
||||||
|
},
|
||||||
|
|
||||||
|
"tsdoc-undefined-tag": {
|
||||||
|
"logLevel": "none"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||||
|
|
||||||
|
"projectFolder": "./src/node",
|
||||||
|
|
||||||
|
"mainEntryPointFilePath": "./dist/temp/index.d.ts",
|
||||||
|
|
||||||
|
"dtsRollup": {
|
||||||
|
"enabled": true,
|
||||||
|
"publicTrimmedFilePath": "./dist/node/index.d.ts"
|
||||||
|
},
|
||||||
|
|
||||||
|
"apiReport": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"docModel": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"tsdocMetadata": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"messages": {
|
||||||
|
"compilerMessageReporting": {
|
||||||
|
"default": {
|
||||||
|
"logLevel": "warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"extractorMessageReporting": {
|
||||||
|
"default": {
|
||||||
|
"logLevel": "warning",
|
||||||
|
"addToApiReportFile": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"ae-missing-release-tag": {
|
||||||
|
"logLevel": "none"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"tsdocMessageReporting": {
|
||||||
|
"default": {
|
||||||
|
"logLevel": "warning"
|
||||||
|
},
|
||||||
|
|
||||||
|
"tsdoc-undefined-tag": {
|
||||||
|
"logLevel": "none"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
// re-export vite client types
|
||||||
|
// with strict installers like pnpm, user won't be able to reference vite/client
|
||||||
|
// in project root
|
||||||
|
/// <reference types="vite/client" />
|
@ -0,0 +1,3 @@
|
|||||||
|
<template>
|
||||||
|
<span>⚡</span>
|
||||||
|
</template>
|
@ -0,0 +1,95 @@
|
|||||||
|
# API Reference
|
||||||
|
|
||||||
|
## Helper Methods
|
||||||
|
|
||||||
|
The following methods are globally importable from `vitepress` and are typically used in custom theme Vue components. However, they are also usable inside `.md` pages because markdown files are compiled into Vue single-file components.
|
||||||
|
|
||||||
|
Methods that start with `use*` indicates that it is a [Vue 3 Composition API](https://vuejs.org/guide/introduction.html#composition-api) function that can only be used inside `setup()` or `<script setup>`.
|
||||||
|
|
||||||
|
### `useData`
|
||||||
|
|
||||||
|
Returns page-specific data. The returned object has the following type:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface VitePressData {
|
||||||
|
site: Ref<SiteData>
|
||||||
|
page: Ref<PageData>
|
||||||
|
theme: Ref<any> // themeConfig from .vitepress/config.js
|
||||||
|
frontmatter: Ref<PageData['frontmatter']>
|
||||||
|
title: Ref<string>
|
||||||
|
description: Ref<string>
|
||||||
|
lang: Ref<string>
|
||||||
|
localePath: Ref<string>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<script setup>
|
||||||
|
import { useData } from 'vitepress'
|
||||||
|
const { theme } = useData()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h1>{{ theme.heroText }}</h1>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
### `useRoute`
|
||||||
|
|
||||||
|
Returns the current route object with the following type:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Route {
|
||||||
|
path: string
|
||||||
|
data: PageData
|
||||||
|
component: Component | null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `useRouter`
|
||||||
|
|
||||||
|
Returns the VitePress router instance so you can programmatically navigate to another page.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Router {
|
||||||
|
route: Route
|
||||||
|
go: (href?: string) => Promise<void>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `withBase`
|
||||||
|
|
||||||
|
- **Type**: `(path: string) => string`
|
||||||
|
|
||||||
|
Appends the configured [`base`](../config/basics#base) to a given URL path. Also see [Base URL](./assets#base-url).
|
||||||
|
|
||||||
|
## Global Components
|
||||||
|
|
||||||
|
VitePress comes with few built-in component that can be used globally. You may use these components in your markdown or your custom theme configuration.
|
||||||
|
|
||||||
|
### `<Content/>`
|
||||||
|
|
||||||
|
The `<Content/>` component displays the rendered markdown contents. Useful [when creating your own theme](./theming).
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<h1>Custom Layout!</h1>
|
||||||
|
<Content />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
### `<ClientOnly/>`
|
||||||
|
|
||||||
|
The `<ClientOnly/>` component renders its slot only at client side.
|
||||||
|
|
||||||
|
Because VitePress applications are server-rendered in Node.js when generating static builds, any Vue usage must conform to the universal code requirements. In short, make sure to only access Browser / DOM APIs in beforeMount or mounted hooks.
|
||||||
|
|
||||||
|
If you are using or demoing components that are not SSR-friendly (for example, contain custom directives), you can wrap them inside the `ClientOnly` component.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<ClientOnly>
|
||||||
|
<NonSSRFriendlyComponent />
|
||||||
|
</ClientOnly>
|
||||||
|
```
|
@ -1,51 +0,0 @@
|
|||||||
# Customization
|
|
||||||
|
|
||||||
You can develop your custom theme by adding the `.vitepress/theme/index.js` file.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
.
|
|
||||||
├─ docs
|
|
||||||
│ ├─ .vitepress
|
|
||||||
│ │ ├─ theme
|
|
||||||
│ │ │ └─ index.js
|
|
||||||
│ │ └─ config.js
|
|
||||||
│ └─ index.md
|
|
||||||
└─ package.json
|
|
||||||
````
|
|
||||||
|
|
||||||
In `.vitepress/theme/index.js`, you must export theme object and register your own theme layout. Let's say you have your own `Layout` component like this.
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<!-- .vitepress/theme/Layout.vue -->
|
|
||||||
<template>
|
|
||||||
<h1>Custom Layout!</h1>
|
|
||||||
<Content/><!-- make sure to include markdown outlet -->
|
|
||||||
</template>
|
|
||||||
```
|
|
||||||
|
|
||||||
Then include it in `.vitepress/theme/index.js`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// .vitepress/theme/index.js
|
|
||||||
import Layout from './Layout.vue'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
Layout,
|
|
||||||
NotFound: () => 'custom 404', // <- this is a Vue 3 functional component
|
|
||||||
enhanceApp({ app, router, siteData }) {
|
|
||||||
// app is the Vue 3 app instance from `createApp()`. router is VitePress'
|
|
||||||
// custom router. `siteData`` is a `ref`` of current site-level metadata.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want to extend the default theme, you can import it from `vitepress/theme`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// .vitepress/theme/index.js
|
|
||||||
import DefaultTheme from 'vitepress/theme'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
...DefaultTheme
|
|
||||||
}
|
|
||||||
```
|
|
@ -1,89 +0,0 @@
|
|||||||
# 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
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## $lang
|
|
||||||
|
|
||||||
The language of the current page. Default: `en-US`.
|
|
||||||
|
|
||||||
## $localePath
|
|
||||||
|
|
||||||
The locale path prefix for the current page. Default: `/`.
|
|
||||||
|
|
||||||
## $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.
|
|
||||||
|
|
||||||
## $withBase
|
|
||||||
|
|
||||||
Helper method to generate correct path by prepending the `base` path configured in `.vitepress/config.js`. It's useful when you want to link to [public files with base path](./assets#public-files).
|
|
||||||
|
|
||||||
```html
|
|
||||||
<img :src="$withBase('/foo.png')" alt="foo">
|
|
||||||
```
|
|
@ -0,0 +1,155 @@
|
|||||||
|
# Theming
|
||||||
|
|
||||||
|
## Using a Custom Theme
|
||||||
|
|
||||||
|
You can enable a custom theme by adding the `.vitepress/theme/index.js` file (the "theme entry file").
|
||||||
|
|
||||||
|
```bash
|
||||||
|
.
|
||||||
|
├─ docs
|
||||||
|
│ ├─ .vitepress
|
||||||
|
│ │ ├─ theme
|
||||||
|
│ │ │ └─ index.js
|
||||||
|
│ │ └─ config.js
|
||||||
|
│ └─ index.md
|
||||||
|
└─ package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
A VitePress custom theme is simply an object containing three properties and is defined as follows:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Theme {
|
||||||
|
Layout: Component // Vue 3 component
|
||||||
|
NotFound?: Component
|
||||||
|
enhanceApp?: (ctx: EnhanceAppContext) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EnhanceAppContext {
|
||||||
|
app: App // Vue 3 app instance
|
||||||
|
router: Router // VitePress router instance
|
||||||
|
siteData: Ref<SiteData>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The theme entry file should export the theme as its default export:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// .vitepress/theme/index.js
|
||||||
|
import Layout from './Layout.vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
Layout,
|
||||||
|
NotFound: () => 'custom 404', // <- this is a Vue 3 functional component
|
||||||
|
enhanceApp({ app, router, siteData }) {
|
||||||
|
// app is the Vue 3 app instance from `createApp()`. router is VitePress'
|
||||||
|
// custom router. `siteData` is a `ref` of current site-level metadata.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
...where the `Layout` component could look like this:
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<!-- .vitepress/theme/Layout.vue -->
|
||||||
|
<template>
|
||||||
|
<h1>Custom Layout!</h1>
|
||||||
|
<Content /><!-- this is where markdown content will be rendered -->
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
The default export is the only contract for a custom theme. Inside your custom theme, it works just like a normal Vite + Vue 3 application. Do note the theme also needs to be [SSR-compatible](./using-vue#browser-api-access-restrictions).
|
||||||
|
|
||||||
|
To distribute a theme, simply export the object in your package entry. To consume an external theme, import and re-export it from the custom theme entry:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// .vitepress/theme/index.js
|
||||||
|
import Theme from 'awesome-vitepress-theme'
|
||||||
|
export default Theme
|
||||||
|
```
|
||||||
|
|
||||||
|
## Extending the Default Theme
|
||||||
|
|
||||||
|
If you want to extend and customize the default theme, you can import it from `vitepress/theme` and augment it in a custom theme entry. Here are some examples of common customizations:
|
||||||
|
|
||||||
|
### Registering Global Components
|
||||||
|
|
||||||
|
```js
|
||||||
|
// .vitepress/theme/index.js
|
||||||
|
import DefaultTheme from 'vitepress/theme'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...DefaultTheme,
|
||||||
|
enhanceApp({ app }) {
|
||||||
|
// register global components
|
||||||
|
app.component('MyGlobalComponent' /* ... */)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Since we are using Vite, you can also leverage Vite's [glob import feature](https://vitejs.dev/guide/features.html#glob-import) to auto register a directory of components.
|
||||||
|
|
||||||
|
### Customizing CSS
|
||||||
|
|
||||||
|
The default theme CSS is customizable by overriding root level CSS variables:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// .vitepress/theme/index.js
|
||||||
|
import DefaultTheme from 'vitepress/theme'
|
||||||
|
import './custom.css'
|
||||||
|
|
||||||
|
export default DefaultTheme
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* .vitepress/theme/custom.css */
|
||||||
|
:root {
|
||||||
|
--c-brand: #646cff;
|
||||||
|
--c-brand-light: #747bff;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
See [default theme CSS variables](https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css) that can be overridden.
|
||||||
|
|
||||||
|
### Layout Slots
|
||||||
|
|
||||||
|
The default theme's `<Layout/>` component has a few slots that can be used to inject content at certain locations of the page. Here's an example of injecting a component into the top of the sidebar:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// .vitepress/theme/index.js
|
||||||
|
import DefaultTheme from 'vitepress/theme'
|
||||||
|
import MyLayout from './MyLayout.vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...DefaultTheme,
|
||||||
|
// override the Layout with a wrapper component that injects the slots
|
||||||
|
Layout: MyLayout
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<!--.vitepress/theme/MyLayout.vue-->
|
||||||
|
<script setup>
|
||||||
|
import DefaultTheme from 'vitepress/theme'
|
||||||
|
const { Layout } = DefaultTheme
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Layout>
|
||||||
|
<template #sidebar-top>My custom sidebar top content</template>
|
||||||
|
</Layout>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
Full list of slots available in the default theme layout:
|
||||||
|
|
||||||
|
- `navbar-search`
|
||||||
|
- `sidebar-top`
|
||||||
|
- `sidebar-bottom`
|
||||||
|
- `page-top-ads`
|
||||||
|
- `page-top`
|
||||||
|
- `page-bottom`
|
||||||
|
- `page-bottom-ads`
|
||||||
|
- Only when `home: true` is enabled via frontmatter:
|
||||||
|
- `home-hero`
|
||||||
|
- `home-features`
|
||||||
|
- `home-footer`
|
@ -0,0 +1,7 @@
|
|||||||
|
// #region snippet
|
||||||
|
function foo() {
|
||||||
|
// ..
|
||||||
|
}
|
||||||
|
// #endregion snippet
|
||||||
|
|
||||||
|
export default foo
|
@ -0,0 +1,3 @@
|
|||||||
|
export default function () {
|
||||||
|
// ..
|
||||||
|
}
|
@ -1,13 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
preset: 'ts-jest',
|
|
||||||
rootDir: __dirname,
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^src/(.*)$': '<rootDir>/src/$1',
|
|
||||||
'^client/(.*)$': '<rootDir>/src/client/$1',
|
|
||||||
'^node/(.*)$': '<rootDir>/src/node/$1',
|
|
||||||
'^shared/(.*)$': '<rootDir>/src/shared/$1',
|
|
||||||
'^tests/(.*)$': '<rootDir>/__tests__/$1'
|
|
||||||
},
|
|
||||||
testMatch: ['<rootDir>/__tests__/**/*.spec.ts'],
|
|
||||||
testPathIgnorePatterns: ['/node_modules/']
|
|
||||||
}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
[build.environment]
|
||||||
|
NODE_VERSION = "16"
|
||||||
|
NPM_FLAGS = "--version" # prevent Netlify npm install
|
||||||
|
|
||||||
|
[build]
|
||||||
|
publish = "docs/.vitepress/dist"
|
||||||
|
command = "npx pnpm i --store=node_modules/.pnpm-store && npm run ci-docs"
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,3 @@
|
|||||||
|
packages:
|
||||||
|
- examples/*
|
||||||
|
- docs
|
@ -0,0 +1,35 @@
|
|||||||
|
import { defineConfig } from 'rollup'
|
||||||
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||||
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
|
import esbuild from 'rollup-plugin-esbuild'
|
||||||
|
import json from '@rollup/plugin-json'
|
||||||
|
import alias from '@rollup/plugin-alias'
|
||||||
|
import { resolve } from 'path'
|
||||||
|
|
||||||
|
const r = (p) => resolve(__dirname, '../', p)
|
||||||
|
const pkg = require('../package.json')
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
input: [r('src/node/index.ts'), r('src/node/cli.ts')],
|
||||||
|
output: {
|
||||||
|
format: 'cjs',
|
||||||
|
dir: r('dist/node')
|
||||||
|
},
|
||||||
|
external: [...Object.keys(pkg.dependencies), 'buffer', 'punycode'],
|
||||||
|
plugins: [
|
||||||
|
alias({
|
||||||
|
entries: {
|
||||||
|
'readable-stream': 'stream'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
nodeResolve(),
|
||||||
|
esbuild({
|
||||||
|
target: 'node12'
|
||||||
|
}),
|
||||||
|
json()
|
||||||
|
],
|
||||||
|
onwarn(warning, warn) {
|
||||||
|
if (warning.code !== 'EVAL') warn(warning)
|
||||||
|
}
|
||||||
|
})
|
@ -1,9 +0,0 @@
|
|||||||
import { Ref, computed } from 'vue'
|
|
||||||
import { usePageData } from './pageData'
|
|
||||||
|
|
||||||
export type FrontmatterRef = Ref<Record<string, any>>
|
|
||||||
|
|
||||||
export function useFrontmatter() {
|
|
||||||
const pageData = usePageData()
|
|
||||||
return computed(() => pageData.value.frontmatter)
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
import { Ref, computed } from 'vue'
|
|
||||||
import { PageData } from '/@types/shared'
|
|
||||||
import { Route, useRoute } from '../router'
|
|
||||||
|
|
||||||
export type PageDataRef = Ref<PageData>
|
|
||||||
|
|
||||||
export function usePageData(route?: Route) {
|
|
||||||
const r = route || useRoute()
|
|
||||||
|
|
||||||
return computed(() => r.data)
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
import serialized from '@siteData'
|
|
||||||
import { SiteData } from '/@types/shared'
|
|
||||||
import { Ref, ref, readonly } from 'vue'
|
|
||||||
|
|
||||||
export type SiteDataRef<T = any> = Ref<SiteData<T>>
|
|
||||||
|
|
||||||
export const siteDataRef: Ref<SiteData> = ref(parse(serialized))
|
|
||||||
|
|
||||||
export function useSiteData<T = any>() {
|
|
||||||
return siteDataRef as Ref<SiteData<T>>
|
|
||||||
}
|
|
||||||
|
|
||||||
function parse(data: string): SiteData {
|
|
||||||
return readonly(JSON.parse(data)) as SiteData
|
|
||||||
}
|
|
||||||
|
|
||||||
// hmr
|
|
||||||
if (import.meta.hot) {
|
|
||||||
import.meta.hot!.accept('/@siteData', (m) => {
|
|
||||||
siteDataRef.value = parse(m.default)
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
import { computed } from 'vue'
|
|
||||||
import { resolveSiteDataByRoute } from '/@shared/config'
|
|
||||||
import { siteDataRef } from './siteData'
|
|
||||||
import { Route, useRoute } from '../router'
|
|
||||||
|
|
||||||
export function useSiteDataByRoute(route?: Route) {
|
|
||||||
const r = route || useRoute()
|
|
||||||
|
|
||||||
return computed(() => {
|
|
||||||
return resolveSiteDataByRoute(siteDataRef.value, r.path)
|
|
||||||
})
|
|
||||||
}
|
|
@ -0,0 +1,73 @@
|
|||||||
|
import { InjectionKey, Ref, shallowRef, readonly, computed, inject } from 'vue'
|
||||||
|
import { Route } from './router'
|
||||||
|
import serializedSiteData from '@siteData'
|
||||||
|
import { resolveSiteDataByRoute, PageData, SiteData } from '../shared'
|
||||||
|
import { withBase } from './utils'
|
||||||
|
|
||||||
|
export const dataSymbol: InjectionKey<VitePressData> = Symbol()
|
||||||
|
|
||||||
|
export interface VitePressData<T = any> {
|
||||||
|
site: Ref<SiteData<T>>
|
||||||
|
page: Ref<PageData>
|
||||||
|
theme: Ref<T>
|
||||||
|
frontmatter: Ref<PageData['frontmatter']>
|
||||||
|
title: Ref<string>
|
||||||
|
description: Ref<string>
|
||||||
|
lang: Ref<string>
|
||||||
|
localePath: Ref<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
// site data is a singleton
|
||||||
|
export type SiteDataRef<T = any> = Ref<SiteData<T>>
|
||||||
|
|
||||||
|
export const siteDataRef: Ref<SiteData> = shallowRef(parse(serializedSiteData))
|
||||||
|
|
||||||
|
function parse(data: string): SiteData {
|
||||||
|
const parsed = JSON.parse(data)
|
||||||
|
return (import.meta.env.DEV ? readonly(parsed) : parsed) as SiteData
|
||||||
|
}
|
||||||
|
|
||||||
|
// hmr
|
||||||
|
if (import.meta.hot) {
|
||||||
|
import.meta.hot!.accept('/@siteData', (m) => {
|
||||||
|
siteDataRef.value = parse(m.default)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// per-app data
|
||||||
|
export function initData(route: Route): VitePressData {
|
||||||
|
const site = computed(() =>
|
||||||
|
resolveSiteDataByRoute(siteDataRef.value, route.path)
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
site,
|
||||||
|
theme: computed(() => site.value.themeConfig),
|
||||||
|
page: computed(() => route.data),
|
||||||
|
frontmatter: computed(() => route.data.frontmatter),
|
||||||
|
lang: computed(() => site.value.lang),
|
||||||
|
localePath: computed(() => {
|
||||||
|
const { langs, lang } = site.value
|
||||||
|
const path = Object.keys(langs).find(
|
||||||
|
(langPath) => langs[langPath].lang === lang
|
||||||
|
)
|
||||||
|
return withBase(path || '/')
|
||||||
|
}),
|
||||||
|
title: computed(() => {
|
||||||
|
return route.data.title
|
||||||
|
? route.data.title + ' | ' + site.value.title
|
||||||
|
: site.value.title
|
||||||
|
}),
|
||||||
|
description: computed(() => {
|
||||||
|
return route.data.description || site.value.description
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useData<T = any>(): VitePressData<T> {
|
||||||
|
const data = inject(dataSymbol)
|
||||||
|
if (!data) {
|
||||||
|
throw new Error('vitepress data not properly injected in app')
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}
|
@ -1,95 +0,0 @@
|
|||||||
import { App, defineAsyncComponent } from 'vue'
|
|
||||||
import { joinPath } from './utils'
|
|
||||||
import { SiteDataRef } from './composables/siteData'
|
|
||||||
import { PageDataRef } from './composables/pageData'
|
|
||||||
import { Content } from './components/Content'
|
|
||||||
import { ClientOnly } from './components/ClientOnly'
|
|
||||||
|
|
||||||
export function mixinGlobalComputed(
|
|
||||||
app: App,
|
|
||||||
site: SiteDataRef,
|
|
||||||
siteByRoute: SiteDataRef,
|
|
||||||
page: PageDataRef
|
|
||||||
): void {
|
|
||||||
Object.defineProperties(app.config.globalProperties, {
|
|
||||||
$site: {
|
|
||||||
get() {
|
|
||||||
return site.value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$siteByRoute: {
|
|
||||||
get() {
|
|
||||||
return siteByRoute.value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$themeConfig: {
|
|
||||||
get() {
|
|
||||||
return siteByRoute.value.themeConfig
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$page: {
|
|
||||||
get() {
|
|
||||||
return page.value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$frontmatter: {
|
|
||||||
get() {
|
|
||||||
return page.value.frontmatter
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$lang: {
|
|
||||||
get() {
|
|
||||||
return siteByRoute.value.lang
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$localePath: {
|
|
||||||
get() {
|
|
||||||
const { locales } = site.value
|
|
||||||
const { lang } = siteByRoute.value
|
|
||||||
|
|
||||||
const path = Object.keys(locales).find(
|
|
||||||
(lp) => locales[lp].lang === lang
|
|
||||||
)
|
|
||||||
|
|
||||||
return (locales && path) || '/'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$title: {
|
|
||||||
get() {
|
|
||||||
return page.value.title
|
|
||||||
? page.value.title + ' | ' + siteByRoute.value.title
|
|
||||||
: siteByRoute.value.title
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$description: {
|
|
||||||
get() {
|
|
||||||
return page.value.description || siteByRoute.value.description
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
$withBase: {
|
|
||||||
value(path: string) {
|
|
||||||
return joinPath(site.value.base, path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function mixinGlobalComponents(app: App) {
|
|
||||||
app.component('Content', Content)
|
|
||||||
app.component('ClientOnly', ClientOnly)
|
|
||||||
app.component(
|
|
||||||
'Debug',
|
|
||||||
import.meta.env.PROD
|
|
||||||
? () => null
|
|
||||||
: defineAsyncComponent(() => import('./components/Debug.vue'))
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,12 +1,12 @@
|
|||||||
<template>
|
|
||||||
<ul v-if="items.length > 0" class="sidebar-links">
|
|
||||||
<SideBarLink v-for="item of items" :key="item.text" :item="item" />
|
|
||||||
</ul>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSideBar } from '../composables/sideBar'
|
import { useSideBar } from '../composables/sideBar'
|
||||||
import { SideBarLink } from './SideBarLink'
|
import { SideBarLink } from './SideBarLink'
|
||||||
|
|
||||||
const items = useSideBar()
|
const items = useSideBar()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ul v-if="items.length > 0" class="sidebar-links">
|
||||||
|
<SideBarLink v-for="item of items" :item="item" />
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<template functional>
|
<template>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
<path d="M19,11H7.4l5.3-5.3c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-7,7c-0.1,0.1-0.2,0.2-0.2,0.3c-0.1,0.2-0.1,0.5,0,0.8c0.1,0.1,0.1,0.2,0.2,0.3l7,7c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.4,13H19c0.6,0,1-0.4,1-1S19.6,11,19,11z" />
|
<path
|
||||||
|
d="M19,11H7.4l5.3-5.3c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-7,7c-0.1,0.1-0.2,0.2-0.2,0.3c-0.1,0.2-0.1,0.5,0,0.8c0.1,0.1,0.1,0.2,0.2,0.3l7,7c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.4,13H19c0.6,0,1-0.4,1-1S19.6,11,19,11z"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<template functional>
|
<template>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
<path d="M19.9,12.4c0.1-0.2,0.1-0.5,0-0.8c-0.1-0.1-0.1-0.2-0.2-0.3l-7-7c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l5.3,5.3H5c-0.6,0-1,0.4-1,1s0.4,1,1,1h11.6l-5.3,5.3c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l7-7C19.8,12.6,19.9,12.5,19.9,12.4z" />
|
<path
|
||||||
|
d="M19.9,12.4c0.1-0.2,0.1-0.5,0-0.8c-0.1-0.1-0.1-0.2-0.2-0.3l-7-7c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l5.3,5.3H5c-0.6,0-1,0.4-1,1s0.4,1,1,1h11.6l-5.3,5.3c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l7-7C19.8,12.6,19.9,12.5,19.9,12.4z"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
import { useSiteData, joinPath } from 'vitepress'
|
|
||||||
|
|
||||||
export function useUrl() {
|
|
||||||
const site = useSiteData()
|
|
||||||
|
|
||||||
function withBase(path: string): string {
|
|
||||||
return joinPath(site.value.base, path)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
withBase
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,146 +1 @@
|
|||||||
export namespace DefaultTheme {
|
export { DefaultTheme } from '../shared'
|
||||||
export interface Config {
|
|
||||||
logo?: string
|
|
||||||
nav?: NavItem[] | false
|
|
||||||
sidebar?: SideBarConfig | MultiSideBarConfig
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GitHub repository following the format <user>/<project>.
|
|
||||||
*
|
|
||||||
* @example `"vuejs/vue-next"`
|
|
||||||
*/
|
|
||||||
repo?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
|
|
||||||
* depending on the provided repo.
|
|
||||||
*
|
|
||||||
* @example `"Contribute!"`
|
|
||||||
*/
|
|
||||||
repoLabel?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If your docs are in a different repository from your main project.
|
|
||||||
*
|
|
||||||
* @example `"vuejs/docs-next"`
|
|
||||||
*/
|
|
||||||
docsRepo?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If your docs are not at the root of the repo.
|
|
||||||
*
|
|
||||||
* @example `"docs"`
|
|
||||||
*/
|
|
||||||
docsDir?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If your docs are in a different branch. Defaults to `master`.
|
|
||||||
*
|
|
||||||
* @example `"next"`
|
|
||||||
*/
|
|
||||||
docsBranch?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable links to edit pages at the bottom of the page.
|
|
||||||
*/
|
|
||||||
editLinks?: boolean
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom text for edit link. Defaults to "Edit this page".
|
|
||||||
*/
|
|
||||||
editLinkText?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show last updated time at the bottom of the page. Defaults to `false`.
|
|
||||||
* If given a string, it will be displayed as a prefix (default value:
|
|
||||||
* "Last Updated").
|
|
||||||
*/
|
|
||||||
lastUpdated?: string | boolean
|
|
||||||
|
|
||||||
prevLinks?: boolean
|
|
||||||
nextLinks?: boolean
|
|
||||||
|
|
||||||
locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
|
|
||||||
|
|
||||||
algolia?: AlgoliaSearchOptions
|
|
||||||
|
|
||||||
carbonAds?: {
|
|
||||||
carbon: string
|
|
||||||
custom?: string
|
|
||||||
placement: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// navbar --------------------------------------------------------------------
|
|
||||||
|
|
||||||
export type NavItem = NavItemWithLink | NavItemWithChildren
|
|
||||||
|
|
||||||
export interface NavItemBase {
|
|
||||||
text: string
|
|
||||||
target?: string
|
|
||||||
rel?: string
|
|
||||||
ariaLabel?: string
|
|
||||||
activeMatch?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NavItemWithLink extends NavItemBase {
|
|
||||||
link: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NavItemWithChildren extends NavItemBase {
|
|
||||||
items: NavItemWithLink[]
|
|
||||||
}
|
|
||||||
|
|
||||||
// sidebar -------------------------------------------------------------------
|
|
||||||
|
|
||||||
export type SideBarConfig = SideBarItem[] | 'auto' | false
|
|
||||||
|
|
||||||
export interface MultiSideBarConfig {
|
|
||||||
[path: string]: SideBarConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SideBarItem = SideBarLink | SideBarGroup
|
|
||||||
|
|
||||||
export interface SideBarLink {
|
|
||||||
text: string
|
|
||||||
link: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SideBarGroup {
|
|
||||||
text: string
|
|
||||||
link?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
collapsable?: boolean
|
|
||||||
|
|
||||||
children: SideBarItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
// algolia ------------------------------------------------------------------
|
|
||||||
// partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
|
|
||||||
export interface AlgoliaSearchOptions {
|
|
||||||
appId?: string
|
|
||||||
apiKey: string
|
|
||||||
indexName: string
|
|
||||||
placeholder?: string
|
|
||||||
searchParameters?: any
|
|
||||||
disableUserPersonalization?: boolean
|
|
||||||
initialQuery?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
// locales -------------------------------------------------------------------
|
|
||||||
|
|
||||||
export interface LocaleConfig {
|
|
||||||
/**
|
|
||||||
* Text for the language dropdown.
|
|
||||||
*/
|
|
||||||
selectText?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Label for this locale in the language dropdown.
|
|
||||||
*/
|
|
||||||
label?: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue