mirror of https://github.com/vuejs/vitepress
parent
e91e0f91b2
commit
1b0424ffb6
@ -0,0 +1,56 @@
|
||||
---
|
||||
outline: deep
|
||||
---
|
||||
|
||||
# 连接到 CMS {#connecting-to-a-cms}
|
||||
|
||||
## 一般的工作流 {#general-workflow}
|
||||
|
||||
将 VitePress 连接到 CMS 主要围绕 [动态路由](./routing#dynamic-routes) 而展开。在继续之前,请确保了解它的工作原理。
|
||||
|
||||
由于每个 CMS 的工作方式都不同,因此我们只能提供一个通用的工作流程,你需要根据具体情况进行调整。
|
||||
|
||||
1. 如果你的 CMS 需要身份验证,请创建一个 `.env` 文件来存储你的 API 令牌并加载它:
|
||||
|
||||
```js
|
||||
// posts/[id].paths.js
|
||||
import { loadEnv } from 'vitepress'
|
||||
|
||||
const env = loadEnv('', process.cwd())
|
||||
```
|
||||
|
||||
2. 从 CMS 获取必要的数据并将其格式调整为合适的路径数据:
|
||||
|
||||
```js
|
||||
export default {
|
||||
async paths() {
|
||||
// 使用相应的 CMS 客户端库 (如果需要的话)
|
||||
const data = await (await fetch('https://my-cms-api', {
|
||||
headers: {
|
||||
// 如果需要token 的话请在这里填写
|
||||
}
|
||||
})).json()
|
||||
|
||||
return data.map(entry => {
|
||||
return {
|
||||
params: { id: entry.id, /* title, authors, date etc. */ },
|
||||
content: entry.content
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. 在页面中渲染内容:
|
||||
|
||||
```md
|
||||
# {{ $params.title }}
|
||||
|
||||
- by {{ $params.author }} on {{ $params.date }}
|
||||
|
||||
<!-- @content -->
|
||||
```
|
||||
|
||||
## 整合指南 {#integration-guides}
|
||||
|
||||
如果你已经写了一篇关于如何将 VitePress 与特定 CMS 集成的指南,请点击下面的“在 GitHub 上编辑此页面”链接将它提交到这里!
|
||||
|
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,32 @@
|
||||
---
|
||||
layout: home
|
||||
|
||||
title: VitePress
|
||||
titleTemplate: 由 Vite 和 Vue 驱动的静态站点生成器
|
||||
|
||||
hero:
|
||||
name: VitePress
|
||||
text: 由 Vite 和 Vue 驱动的静态站点生成器
|
||||
tagline: 简单、强大、快速。就是你想要的现代 SSG 框架!
|
||||
actions:
|
||||
- theme: brand
|
||||
text: 认识 VitePress
|
||||
link: /zh/guide/what-is-vitepress
|
||||
- theme: alt
|
||||
text: GitHub
|
||||
link: https://github.com/vuejs/vitepress
|
||||
|
||||
features:
|
||||
- icon: 📝
|
||||
title: 专注内容
|
||||
details: 只需 Markdown 即可轻松创建美观的文档站点。
|
||||
- icon: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><g fill="none"><path fill="url(#a)" d="m29.884 6.146-13.142 23.5a.714.714 0 0 1-1.244.005L2.096 6.148a.714.714 0 0 1 .746-1.057l13.156 2.352a.714.714 0 0 0 .253 0l12.881-2.348a.714.714 0 0 1 .752 1.05z"/><path fill="url(#b)" d="M22.264 2.007 12.54 3.912a.357.357 0 0 0-.288.33l-.598 10.104a.357.357 0 0 0 .437.369l2.707-.625a.357.357 0 0 1 .43.42l-.804 3.939a.357.357 0 0 0 .454.413l1.672-.508a.357.357 0 0 1 .454.414l-1.279 6.187c-.08.387.435.598.65.267l.143-.222 7.925-15.815a.357.357 0 0 0-.387-.51l-2.787.537a.357.357 0 0 1-.41-.45l1.818-6.306a.357.357 0 0 0-.412-.45z"/><defs><linearGradient id="a" x1="6" x2="235" y1="33" y2="344" gradientTransform="translate(1.34 1.894) scale(.07142)" gradientUnits="userSpaceOnUse"><stop stop-color="#41D1FF"/><stop offset="1" stop-color="#BD34FE"/></linearGradient><linearGradient id="b" x1="194.651" x2="236.076" y1="8.818" y2="292.989" gradientTransform="translate(1.34 1.894) scale(.07142)" gradientUnits="userSpaceOnUse"><stop stop-color="#FFEA83"/><stop offset=".083" stop-color="#FFDD35"/><stop offset="1" stop-color="#FFA800"/></linearGradient></defs></g></svg>
|
||||
title: 享受 Vite 无可比拟的体验
|
||||
details: 服务器即时启动,闪电般的热更新,还可以使用基于 Vite 生态的插件。
|
||||
- icon: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path fill="#41b883" d="M24.4 3.925H30l-14 24.15L2 3.925h10.71l3.29 5.6 3.22-5.6Z"/><path fill="#41b883" d="m2 3.925 14 24.15 14-24.15h-5.6L16 18.415 7.53 3.925Z"/><path fill="#35495e" d="M7.53 3.925 16 18.485l8.4-14.56h-5.18L16 9.525l-3.29-5.6Z"/></svg>
|
||||
title: 使用 Vue 自定义
|
||||
details: 直接在 Markdown 中使用 Vue 语法和组件,或者使用 Vue 组件构建自定义主题。
|
||||
- icon: 🚀
|
||||
title: 速度真的很快!
|
||||
details: 采用静态 HTML 实现快速的页面初次加载,使用客户端路由实现快速的页面切换导航。
|
||||
---
|
||||
@ -0,0 +1,74 @@
|
||||
# 命令行接口 {#command-line-interface}
|
||||
|
||||
## `vitepress dev`
|
||||
|
||||
使用指定目录作为根目录来启动 VitePress 开发服务器。默认为当前目录。在当前目录下运行时也可以省略 `dev` 命令。
|
||||
|
||||
### 用法
|
||||
|
||||
```sh
|
||||
# 从当前目录开始,省略 `dev`
|
||||
vitepress
|
||||
|
||||
# 从子目录开始
|
||||
vitepress dev [root]
|
||||
```
|
||||
|
||||
### 选项
|
||||
|
||||
| 选项 | 说明 |
|
||||
| --------------- | ------------------------------------------ |
|
||||
| `--open [path]` | 启动时打开浏览器 (`boolean \| string`) |
|
||||
| `--port <port>` | 指定端口 (`number`) |
|
||||
| `--base <path>` | 公共基础路径 (default: `/`) (`string`) |
|
||||
| `--cors` | 启用 CORS |
|
||||
| `--strictPort` | 如果指定的端口已被占用则退出 (`boolean`) |
|
||||
| `--force` | 强制优化程序忽略缓存并重新绑定 (`boolean`) |
|
||||
|
||||
## `vitepress build`
|
||||
|
||||
构建用于生产的 VitePress 站点。
|
||||
|
||||
### 用法 {#usage}
|
||||
|
||||
```sh
|
||||
vitepress build [root]
|
||||
```
|
||||
|
||||
### 选项 {#options}
|
||||
|
||||
| 选项 | 说明 |
|
||||
| ------------------------------ | ------------------------------------------------------------------------------------------------- |
|
||||
| `--mpa` (experimental) | 在没有客户端 hydration 的 [MPA 模式](../guide/mpa-mode) 下构建 (`boolean`) |
|
||||
| `--base <path>` | 公共基础路径 (default: `/`) (`string`) |
|
||||
| `--target <target>` | 转译目标 (default: `"modules"`) (`string`) |
|
||||
| `--outDir <dir>` | 输出目录 (default: `.vitepress/dist`) (`string`) |
|
||||
| `--minify [minifier]` | 启用/禁用压缩,或指定要使用的压缩程序 (default: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
|
||||
| `--assetsInlineLimit <number>` | 静态资源 base64 内联阈值(以字节为单位) (default: `4096`) (`number`) |
|
||||
|
||||
## `vitepress preview`
|
||||
|
||||
在本地预览生产版本。
|
||||
|
||||
### 用法 {#usage-1}
|
||||
|
||||
```sh
|
||||
vitepress preview [root]
|
||||
```
|
||||
|
||||
### 选项 {#options-1}
|
||||
|
||||
| 选项 | 说明 |
|
||||
| --------------- | -------------------------------------- |
|
||||
| `--base <path>` | 公共基础路径 (default: `/`) (`string`) |
|
||||
| `--port <port>` | 指定端口 (`number`) |
|
||||
|
||||
## `vitepress init`
|
||||
|
||||
在当前目录中启动[安装向导](../guide/getting-started#setup-wizard)。
|
||||
|
||||
### 用法
|
||||
|
||||
```sh
|
||||
vitepress init
|
||||
```
|
||||
@ -0,0 +1,83 @@
|
||||
# 标记 {#badge}
|
||||
|
||||
徽标可让你为标题添加状态。例如,指定部分的类型或支持的版本可能很有用。
|
||||
|
||||
## 用法 {#usage}
|
||||
|
||||
你可以使用全局组件 `Badge` 。
|
||||
|
||||
```html
|
||||
### Title <Badge type="info" text="default" />
|
||||
### Title <Badge type="tip" text="^1.9.0" />
|
||||
### Title <Badge type="warning" text="beta" />
|
||||
### Title <Badge type="danger" text="caution" />
|
||||
```
|
||||
|
||||
上面的代码渲染如下:
|
||||
|
||||
### Title <Badge type="info" text="default" />
|
||||
### Title <Badge type="tip" text="^1.9.0" />
|
||||
### Title <Badge type="warning" text="beta" />
|
||||
### Title <Badge type="danger" text="caution" />
|
||||
|
||||
## 自定义 `children` {#custom-children}
|
||||
|
||||
`<Badge>` 接受 `子节点`, 这将显示在徽标中。
|
||||
|
||||
```html
|
||||
### Title <Badge type="info">custom element</Badge>
|
||||
```
|
||||
|
||||
### Title <Badge type="info">custom element</Badge>
|
||||
|
||||
## 自定义不同类型徽标的背景色 {#customize-type-color}
|
||||
|
||||
你可以通过覆盖 css 变量 `background-color` 来自定义不同类型 `<Badge />` 的背景色。以下是默认值。
|
||||
|
||||
```css
|
||||
:root {
|
||||
--vp-badge-info-border: var(--vp-c-divider-light);
|
||||
--vp-badge-info-text: var(--vp-c-text-2);
|
||||
--vp-badge-info-bg: var(--vp-c-white-soft);
|
||||
|
||||
--vp-badge-tip-border: var(--vp-c-green-dimm-1);
|
||||
--vp-badge-tip-text: var(--vp-c-green-darker);
|
||||
--vp-badge-tip-bg: var(--vp-c-green-dimm-3);
|
||||
|
||||
--vp-badge-warning-border: var(--vp-c-yellow-dimm-1);
|
||||
--vp-badge-warning-text: var(--vp-c-yellow-darker);
|
||||
--vp-badge-warning-bg: var(--vp-c-yellow-dimm-3);
|
||||
|
||||
--vp-badge-danger-border: var(--vp-c-red-dimm-1);
|
||||
--vp-badge-danger-text: var(--vp-c-red-darker);
|
||||
--vp-badge-danger-bg: var(--vp-c-red-dimm-3);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--vp-badge-info-border: var(--vp-c-divider-light);
|
||||
--vp-badge-info-bg: var(--vp-c-black-mute);
|
||||
|
||||
--vp-badge-tip-border: var(--vp-c-green-dimm-2);
|
||||
--vp-badge-tip-text: var(--vp-c-green-light);
|
||||
|
||||
--vp-badge-warning-border: var(--vp-c-yellow-dimm-2);
|
||||
--vp-badge-warning-text: var(--vp-c-yellow-light);
|
||||
|
||||
--vp-badge-danger-border: var(--vp-c-red-dimm-2);
|
||||
--vp-badge-danger-text: var(--vp-c-red-light);
|
||||
}
|
||||
```
|
||||
|
||||
## `<Badge>`
|
||||
|
||||
`<Badge>` 组件接受以下属性:
|
||||
|
||||
```ts
|
||||
interface Props {
|
||||
// When `<slot>` is passed, this value gets ignored.
|
||||
text?: string
|
||||
|
||||
// Defaults to `tip`.
|
||||
type?: 'info' | 'tip' | 'warning' | 'danger'
|
||||
}
|
||||
```
|
||||
@ -0,0 +1,62 @@
|
||||
# 编辑链接 {#edit-link}
|
||||
|
||||
## 全局配置 {#site-level-config}
|
||||
|
||||
编辑链接让你可以显示一个链接,以在 GitHub 或 GitLab 等 Git 管理服务上编辑页面。要启用它,请将 `themeConfig.editLink` 选项添加到你的配置中。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
editLink: {
|
||||
pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path',
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
`pattern` 选项定义链接的 URL 结构,并且 `:path` 将被替换为页面路径。
|
||||
|
||||
你还可以放置一个接受“relativePath(相对路径)”作为参数并返回 URL 字符串的纯函数。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
editLink: {
|
||||
pattern: ({ relativePath }) => {
|
||||
if (relativePath.startsWith('packages/')) {
|
||||
return `https://github.com/acme/monorepo/edit/main/${relativePath}`
|
||||
} else {
|
||||
return `https://github.com/acme/monorepo/edit/main/docs/${relativePath}`
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
::: details 它不应该有副作用,也不应该访问其范围之外的任何东西,因为它将在浏览器中被序列化和执行。
|
||||
It should not have side-effects nor access anything outside of its scope since it will be serialized and executed in the browser.
|
||||
:::
|
||||
|
||||
默认情况下,这将在文档页面底部添加链接文本"Edit this page"。你可以通过定义 `text` 选项来自定义此文本。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
editLink: {
|
||||
pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path',
|
||||
text: 'Edit this page on GitHub',
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## Frontmatter 配置 {#frontmatter-config}
|
||||
|
||||
可以使用 frontmatter 上的 `editLink` 选项单独禁用某个页面的编辑链接:
|
||||
|
||||
```yaml
|
||||
---
|
||||
editLink: false
|
||||
---
|
||||
```
|
||||
@ -0,0 +1,22 @@
|
||||
# 最后更新 {#last-updated}
|
||||
|
||||
最近一条内容的更新时间会显示在页面右下角。要启用它,请将 `lastUpdated` 选项添加到你的配置中。
|
||||
|
||||
## 全局配置 {#site-level-config}
|
||||
|
||||
```js
|
||||
export default {
|
||||
lastUpdated: true
|
||||
}
|
||||
```
|
||||
|
||||
## Frontmatter 配置 {#frontmatter-config}
|
||||
|
||||
可以使用 frontmatter 上的 `lastUpdated` 选项单独禁用某个页面的最后更新展示:
|
||||
|
||||
```yaml
|
||||
---
|
||||
lastUpdated: false
|
||||
---
|
||||
```
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
# 上下页链接 {#prev-next-links}
|
||||
|
||||
你可以自定义上(下)一篇链接的文本。如果 你想在 上(下)一篇 链接上显示与侧边栏上不同的文本(默认显示侧边栏的文本),这将很有帮助。
|
||||
你可以自定义上一页和下一页的文本和链接(显示在文档页脚处)。如果你想要的文本与边栏上的文本不同,这会很有帮助。此外,还可以禁用侧边栏中未包含页面的页脚或链接
|
||||
|
||||
## prev
|
||||
|
||||
- Type: `string | false | { text?: string; link?: string }`
|
||||
|
||||
- Details:
|
||||
|
||||
指定要在指向上一页的链接上显示的文本/链接。如果你没有在 `frontmatter` 中设置它,文本/链接将从侧边栏配置中推断出来。
|
||||
|
||||
- 示例:
|
||||
|
||||
- 仅自定义文本:
|
||||
|
||||
```yaml
|
||||
---
|
||||
prev: 'Get Started | Markdown'
|
||||
---
|
||||
```
|
||||
|
||||
- 自定义文本和链接:
|
||||
|
||||
```yaml
|
||||
---
|
||||
prev:
|
||||
text: 'Markdown'
|
||||
link: '/guide/markdown'
|
||||
---
|
||||
```
|
||||
|
||||
- 隐藏上一页:
|
||||
|
||||
```yaml
|
||||
---
|
||||
prev: false
|
||||
---
|
||||
```
|
||||
|
||||
## next
|
||||
|
||||
与 `prev` 相同,但用于下一页。
|
||||
@ -0,0 +1,182 @@
|
||||
# 侧边栏 {#sidebar}
|
||||
|
||||
侧边栏是文档的主要导航块。 你可以在 [`themeConfig.sidebar`](./default-theme-config#sidebar) 中配置侧边栏菜单。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
sidebar: [
|
||||
{
|
||||
text: 'Guide',
|
||||
items: [
|
||||
{ text: 'Introduction', link: '/introduction' },
|
||||
{ text: 'Getting Started', link: '/getting-started' },
|
||||
...
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 基本用法 {#the-basics}
|
||||
|
||||
侧边栏菜单的最简单形式是传入一个链接数组。第一级项目定义侧边栏的“部分”。它应该包含作为小标题的 `text` 和作为实际导航链接的 `items`。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
sidebar: [
|
||||
{
|
||||
text: 'Section Title A',
|
||||
items: [
|
||||
{ text: 'Item A', link: '/item-a' },
|
||||
{ text: 'Item B', link: '/item-b' },
|
||||
...
|
||||
]
|
||||
},
|
||||
{
|
||||
text: 'Section Title B',
|
||||
items: [
|
||||
{ text: 'Item C', link: '/item-c' },
|
||||
{ text: 'Item D', link: '/item-d' },
|
||||
...
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
每个 `link` 都应指定以 `/` 开头的实际文件的路径。如果在链接末尾添加斜杠,它将显示相应目录的 `index.md`。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
sidebar: [
|
||||
{
|
||||
text: 'Guide',
|
||||
items: [
|
||||
// This shows `/guide/index.md` page.
|
||||
{ text: 'Introduction', link: '/guide/' },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
你可以进一步将侧边栏项目嵌入到 6 级深度,从根级别上计数。请注意,深度超过 6 级嵌套物品被忽略,并且不会在侧边栏上显示。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
sidebar: [
|
||||
{
|
||||
text: 'Level 1',
|
||||
items: [
|
||||
{
|
||||
text: 'Level 2',
|
||||
items: [
|
||||
{
|
||||
text: 'Level 3',
|
||||
items: [
|
||||
...
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 多侧边栏 {#multiple-sidebars}
|
||||
|
||||
你可能会根据页面路径显示不同的侧边栏。例如,如本网站所示,你可能希望在文档中创建单独的侧边栏,例如“指引”页面和“配置参考”页面。
|
||||
|
||||
为此,首先将你的页面组织到每个所需部分的目录中:
|
||||
|
||||
```
|
||||
.
|
||||
├─ guide/
|
||||
│ ├─ index.md
|
||||
│ ├─ one.md
|
||||
│ └─ two.md
|
||||
└─ config/
|
||||
├─ index.md
|
||||
├─ three.md
|
||||
└─ four.md
|
||||
```
|
||||
|
||||
然后,更新你的配置以定义每个部分的侧边栏。这一次,你应该传递一个对象而不是数组。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
sidebar: {
|
||||
// This sidebar gets displayed when a user
|
||||
// is on `guide` directory.
|
||||
'/guide/': [
|
||||
{
|
||||
text: 'Guide',
|
||||
items: [
|
||||
{ text: 'Index', link: '/guide/' },
|
||||
{ text: 'One', link: '/guide/one' },
|
||||
{ text: 'Two', link: '/guide/two' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// This sidebar gets displayed when a user
|
||||
// is on `config` directory.
|
||||
'/config/': [
|
||||
{
|
||||
text: 'Config',
|
||||
items: [
|
||||
{ text: 'Index', link: '/config/' },
|
||||
{ text: 'Three', link: '/config/three' },
|
||||
{ text: 'Four', link: '/config/four' },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## 可折叠的侧边栏组 {#collapsible-sidebar-groups}
|
||||
|
||||
通过向侧边栏组添加 `collapsed` 选项,它会显示一个切换按钮来隐藏/显示每个部分。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
sidebar: [
|
||||
{
|
||||
text: 'Section Title A',
|
||||
collapsed: false,
|
||||
items: [...]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
默认情况下,所有部分都是“打开”的。如果 你希望它们在初始页面加载时“关闭”,请将 `collapsed` 选项设置为 `true`。
|
||||
|
||||
```js
|
||||
export default {
|
||||
themeConfig: {
|
||||
sidebar: [
|
||||
{
|
||||
text: 'Section Title A',
|
||||
collapsed: true,
|
||||
items: [...]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -0,0 +1,254 @@
|
||||
<script setup>
|
||||
import { VPTeamMembers } from 'vitepress/theme'
|
||||
|
||||
const members = [
|
||||
// {
|
||||
// avatar: 'https://github.com/yyx990803.png',
|
||||
// name: 'Evan You',
|
||||
// title: 'Creator',
|
||||
// links: [
|
||||
// { icon: 'github', link: 'https://github.com/yyx990803' },
|
||||
// { icon: 'twitter', link: 'https://twitter.com/youyuxi' }
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// avatar: 'https://github.com/kiaking.png',
|
||||
// name: 'Kia King Ishii',
|
||||
// title: 'Developer',
|
||||
// links: [
|
||||
// { icon: 'github', link: 'https://github.com/kiaking' },
|
||||
// { icon: 'twitter', link: 'https://twitter.com/KiaKing85' }
|
||||
// ]
|
||||
// }
|
||||
{
|
||||
avatar: 'https://avatars.githubusercontent.com/u/50388827?v=4',
|
||||
name: 'VanchKong',
|
||||
title: 'Translator',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/vanchKong' },
|
||||
]
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
# 团队页 {#team-page}
|
||||
|
||||
如果你想介绍你的团队,你可以使用 Team components 来构建团队页面。有两种使用这些组件的方法。一种是将其嵌入文档页面,另一种是创建完整的团队页面。
|
||||
|
||||
## 在页面中显示团队成员 {#show-team-members-in-a-page}
|
||||
|
||||
你可以在任何页面上使用从 `vitepress/theme` 暴露出的公共组件 `<VPTeamMembers>` 显示团队成员。
|
||||
|
||||
```html
|
||||
<script setup>
|
||||
import { VPTeamMembers } from 'vitepress/theme'
|
||||
|
||||
const members = [
|
||||
{
|
||||
avatar: 'https://www.github.com/yyx990803.png',
|
||||
name: 'Evan You',
|
||||
title: 'Creator',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/yyx990803' },
|
||||
{ icon: 'twitter', link: 'https://twitter.com/youyuxi' }
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
</script>
|
||||
|
||||
# 我们的团队,向我们出色的团队问好。
|
||||
|
||||
<VPTeamMembers size="small" :members="members" />
|
||||
```
|
||||
|
||||
以上将在卡片外观元素中显示团队成员。它应该显示类似于下面的内容。
|
||||
|
||||
<VPTeamMembers size="small" :members="members" />
|
||||
|
||||
`<VPTeamMembers>` 组件有 2 种不同的尺寸, `small` 和 `medium`。虽然它取决于为你的偏好,但通常尺寸在文档页面中使用时 `small` 应该更适合。此外,你可以为每个成员添加更多属性,例如添加“描述”或“赞助”按钮。在 [`<VPTeamMembers>`](#vpteammembers)中了解更多信息。
|
||||
|
||||
在文档页面中嵌入团队成员对于小型团队来说非常有用,某种情况下,完整的贡献团队可能太大了,可以引入部分成员作为文档上下文的参考。
|
||||
|
||||
如果你有大量成员,或者只是想有更多空间来展示团队成员,请考虑[创建一个完整的团队页面](#create-a-full-team-page)。
|
||||
|
||||
## 创建一个完整的团队页面 {#create-a-full-team-page}
|
||||
|
||||
除了将团队成员添加到 doc 页面,你还可以创建一个完整的团队页面,类似于创建自定义[默认主题:主页](./default-theme-home-page)的方式。
|
||||
|
||||
要创建团队页面,首先,创建一个新的 md 文件。文件名无所谓,这里我们就叫它 `team.md` 吧。在这个文件中,在 frontmatter 设置 `layout: page`,然后你可以使用 `TeamPage` 组件来组成你的页面结构。
|
||||
|
||||
```html
|
||||
---
|
||||
layout: page
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
VPTeamPage,
|
||||
VPTeamPageTitle,
|
||||
VPTeamMembers
|
||||
} from 'vitepress/theme'
|
||||
|
||||
const members = [
|
||||
{
|
||||
avatar: 'https://www.github.com/yyx990803.png',
|
||||
name: 'Evan You',
|
||||
title: 'Creator',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/yyx990803' },
|
||||
{ icon: 'twitter', link: 'https://twitter.com/youyuxi' }
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
</script>
|
||||
|
||||
<VPTeamPage>
|
||||
<VPTeamPageTitle>
|
||||
<template #title> Our Team </template>
|
||||
<template #lead> The development of VitePress is guided by an international team, some of whom have chosen to be featured below. </template>
|
||||
</VPTeamPageTitle>
|
||||
<VPTeamMembers :members="members" />
|
||||
</VPTeamPage>
|
||||
```
|
||||
|
||||
创建完整的团队页面时,请记住用 `<VPTeamPage>` 组件包装所有团队相关组件,以获得正确的布局结构,如间距。
|
||||
|
||||
`<VPPageTitle>` 组件添加页面标题部分。标题是 `<h1>` 标题。使用 `#title` 和 `#lead` 插槽来介绍你的团队。
|
||||
|
||||
`<VPMembers>` 和在 doc 页面中使用时一样。它将显示成员列表。
|
||||
|
||||
### 添加分段以划分团队成员 {#add-sections-to-divide-team-members}
|
||||
|
||||
你可以将“分段”添加到团队页面。例如,你可能有不同类型的团队成员,例如核心团队成员和社区合作伙伴。你可以将这些成员分成几个部分,以更好地解释每组的角色。
|
||||
|
||||
为此,将 `<VPTeamPageSection>` 组件添加到我们之前创建的 `team.md` 文件中。
|
||||
|
||||
```html
|
||||
---
|
||||
layout: page
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
VPTeamPage,
|
||||
VPTeamPageTitle,
|
||||
VPTeamMembers,
|
||||
VPTeamPageSection
|
||||
} from 'vitepress/theme'
|
||||
|
||||
const coreMembers = [...]
|
||||
const partners = [...]
|
||||
</script>
|
||||
|
||||
<VPTeamPage>
|
||||
<VPTeamPageTitle>
|
||||
<template #title>Our Team</template>
|
||||
<template #lead>...</template>
|
||||
</VPTeamPageTitle>
|
||||
<VPTeamMembers size="medium" :members="coreMembers" />
|
||||
<VPTeamPageSection>
|
||||
<template #title>Partners</template>
|
||||
<template #lead>...</template>
|
||||
<template #members>
|
||||
<VPTeamMembers size="small" :members="partners" />
|
||||
</template>
|
||||
</VPTeamPageSection>
|
||||
</VPTeamPage>
|
||||
```
|
||||
|
||||
`<VPTeamPageSection>` 组件可以有类似于 `VPTeamPageTitle` 组件的 `#title` 和 `#lead` 插槽,还有用于显示团队成员的 `#members` 插槽。
|
||||
|
||||
请记住将 `<VPTeamMembers>` 组件放入 `#members` 插槽中。
|
||||
|
||||
## `<VPTeamMembers>`
|
||||
|
||||
`<VPTeamMembers>` 组件显示给定的成员列表。
|
||||
|
||||
```html
|
||||
<VPTeamMembers
|
||||
size="medium"
|
||||
:members="[
|
||||
{ avatar: '...', name: '...' },
|
||||
{ avatar: '...', name: '...' },
|
||||
...
|
||||
]" />
|
||||
```
|
||||
|
||||
```ts
|
||||
interface Props {
|
||||
// Size of each members. Defaults to `medium`.
|
||||
size?: 'small' | 'medium'
|
||||
|
||||
// List of members to display.
|
||||
members: TeamMember[]
|
||||
}
|
||||
|
||||
interface TeamMember {
|
||||
// Avatar image for the member.
|
||||
avatar: string
|
||||
|
||||
// Name of the member.
|
||||
name: string
|
||||
|
||||
// Title to be shown below member's name.
|
||||
// e.g. Developer, Software Engineer, etc.
|
||||
title?: string
|
||||
|
||||
// Organization that the member belongs.
|
||||
org?: string
|
||||
|
||||
// URL for the organization.
|
||||
orgLink?: string
|
||||
|
||||
// Description for the member.
|
||||
desc?: string
|
||||
|
||||
// Social links. e.g. GitHub, Twitter, etc. You may pass in
|
||||
// the Social Links object here.
|
||||
// See: https://vitepress.dev/reference/default-theme-config.html#sociallinks
|
||||
links?: SocialLink[]
|
||||
|
||||
// URL for the sponsor page for the member.
|
||||
sponsor?: string
|
||||
}
|
||||
```
|
||||
|
||||
## `<VPTeamPage>`
|
||||
|
||||
::: details 创建完整团队页面时的根组件。它只接受一个插槽。它将设置所有传入的团队相关组件的样式。
|
||||
The root component when creating a full team page. It only accepts a single slot. It will style all passed in team related components.
|
||||
:::
|
||||
|
||||
## `<VPTeamPageTitle>`
|
||||
|
||||
添加页面的标题。最好在一开始就在 `<VPTeamPage>` 下使用。它接受 `#title` 和 `#lead` 插槽。
|
||||
|
||||
```html
|
||||
<VPTeamPage>
|
||||
<VPTeamPageTitle>
|
||||
<template #title> Our Team </template>
|
||||
<template #lead> The development of VitePress is guided by an international team, some of whom have chosen to be featured below. </template>
|
||||
</VPTeamPageTitle>
|
||||
</VPTeamPage>
|
||||
```
|
||||
|
||||
## `<VPTeamPageSection>`
|
||||
|
||||
在团队页面中创建一个“分段”。它接受 `#title`、`#lead` 和 `#members` 插槽。你可以在 `<VPTeamPage>` 中添加任意数量的分段。
|
||||
|
||||
```html
|
||||
<VPTeamPage>
|
||||
...
|
||||
<VPTeamPageSection>
|
||||
<template #title>Partners</template>
|
||||
<template #lead>Lorem ipsum...</template>
|
||||
<template #members>
|
||||
<VPTeamMembers :members="data" />
|
||||
</template>
|
||||
</VPTeamPageSection>
|
||||
</VPTeamPage>
|
||||
```
|
||||
|
||||
[未出现在侧边栏的完整团队页面](./team)
|
||||
@ -0,0 +1,169 @@
|
||||
---
|
||||
outline: deep
|
||||
---
|
||||
|
||||
# Frontmatter 配置 {#frontmatter-config}
|
||||
|
||||
Frontmatter 支持基于页面的配置。在每个 markdown 文件中,你可以使用 frontmatter 配置来覆写站点级别或主题级别的配置选项。此外,还有一些配置选项只能在 frontmatter 中定义。
|
||||
|
||||
示例用法:
|
||||
|
||||
```md
|
||||
---
|
||||
title: Docs with VitePress
|
||||
editLink: true
|
||||
---
|
||||
```
|
||||
|
||||
你可以通过 Vue 表达式中的 `$frontmatter` 全局变量访问 frontmatter 数据:
|
||||
|
||||
```md
|
||||
{{ $frontmatter.title }}
|
||||
```
|
||||
|
||||
## 标题 {#title}
|
||||
|
||||
- key: `title`
|
||||
- Type: `string`
|
||||
|
||||
Title for the page. It's same as [config.title](./site-config#title), and it overrides the site-level config.
|
||||
|
||||
```yaml
|
||||
---
|
||||
title: VitePress
|
||||
---
|
||||
```
|
||||
|
||||
## 标题模板 {#titletemplate}
|
||||
|
||||
- key: `titleTemplate`
|
||||
- Type: `string | boolean`
|
||||
|
||||
标题的后缀。它与 [config.titleTemplate](./site-config#titletemplate) 相同,它会覆盖站点级别的配置。
|
||||
|
||||
```yaml
|
||||
---
|
||||
title: VitePress
|
||||
titleTemplate: Vite & Vue powered static site generator
|
||||
---
|
||||
```
|
||||
|
||||
## 描述 {#description}
|
||||
|
||||
- key: `description`
|
||||
- Type: `string`
|
||||
|
||||
页面的描述。它与 [config.description](./site-config#description) 相同,它会覆盖站点级别的配置。
|
||||
|
||||
```yaml
|
||||
---
|
||||
description: VitePress
|
||||
---
|
||||
```
|
||||
|
||||
## 头部标签 {#head}
|
||||
|
||||
- key: `head`
|
||||
- Type: `HeadConfig[]`
|
||||
|
||||
指定要为当前页面注入的额外 head 标签。将附加在站点级配置注入的头部标签之后。
|
||||
|
||||
```yaml
|
||||
---
|
||||
head:
|
||||
- - meta
|
||||
- name: description
|
||||
content: hello
|
||||
- - meta
|
||||
- name: keywords
|
||||
content: super duper SEO
|
||||
---
|
||||
```
|
||||
|
||||
```ts
|
||||
type HeadConfig = [string, Record<string, string>] | [string, Record<string, string>, string]
|
||||
```
|
||||
|
||||
## 仅默认主题 {#default-theme-only}
|
||||
|
||||
以下 frontmatter 选项仅在使用默认主题时适用。
|
||||
|
||||
### 布局 <Badge type="info" text="default theme only" /> {#layout}
|
||||
|
||||
- key: `layout`
|
||||
- Type: `doc | home | page`
|
||||
- Default: `doc`
|
||||
|
||||
指定页面的布局。
|
||||
|
||||
- `doc` - 它将默认文档样式应用于 markdown 内容。
|
||||
- `home` - “主页”的特殊布局。你可以添加额外的选项,例如 `hero` 和 `features`,以快速创建漂亮的落地页。
|
||||
- `page` - 表现类似于 `doc`,但它不对内容应用任何样式。当你想创建一个完全自定义的页面时很有用。
|
||||
|
||||
```yaml
|
||||
---
|
||||
layout: doc
|
||||
---
|
||||
```
|
||||
|
||||
### hero <Badge type="info" text="default theme only" /> <Badge type="info" text="Home page only" />
|
||||
|
||||
当 `layout` 设置为 `home` 时,定义主页 hero 部分的内容。更多详细信息:[默认主题:主页](./default-theme-home-page)。
|
||||
|
||||
### features <Badge type="info" text="default theme only" /> <Badge type="info" text="Home page only" />
|
||||
|
||||
定义当`layout` 设置为 `home` 时要在 features 部分中显示的项目。更多详细信息:[默认主题:主页](./default-theme-home-page)。
|
||||
|
||||
### 大纲开关 <Badge type="info" text="default theme only" /> {#aside}
|
||||
|
||||
- key: `aside`
|
||||
- Type: `boolean | 'left'`
|
||||
- Default: `true`
|
||||
|
||||
定义 aside 组件在 `doc` 布局中的位置。
|
||||
|
||||
将此值设置为 `false` 可禁用 aside 容器。\
|
||||
将此值设置为 `true` 会将 aside 渲染到右侧。\
|
||||
将此值设置为 `left` 会将 aside 渲染到左侧。
|
||||
|
||||
```yaml
|
||||
---
|
||||
aside: false
|
||||
---
|
||||
```
|
||||
|
||||
### 大纲层级 <Badge type="info" text="default theme only" /> {#outline}
|
||||
|
||||
- key: `outline`
|
||||
- Type: `number | [number, number] | 'deep' | false`
|
||||
- Default: `2`
|
||||
|
||||
大纲中显示的标题级别。它与 [config.themeConfig.outline](./default-theme-config#outline) 相同,它会覆盖主题配置。
|
||||
|
||||
### 最近更新时间 <Badge type="info" text="default theme only" /> {#lastupdated}
|
||||
|
||||
- key: `lastUpdated`
|
||||
- Type: `boolean`
|
||||
- Default: `true`
|
||||
|
||||
是否在当前页面的页脚中显示[最近更新时间](./default-theme-last-updated)的文本。
|
||||
|
||||
```yaml
|
||||
---
|
||||
lastUpdated: false
|
||||
---
|
||||
```
|
||||
|
||||
### 编辑链接 <Badge type="info" text="default theme only" /> {#editlink}
|
||||
|
||||
- key: `editLink`
|
||||
- Type: `boolean`
|
||||
- Default: `true`
|
||||
|
||||
是否在当前页的页脚显示[编辑链接](./default-theme-edit-link)。
|
||||
|
||||
```yaml
|
||||
---
|
||||
editLink: false
|
||||
---
|
||||
```
|
||||
@ -0,0 +1,80 @@
|
||||
---
|
||||
layout: page
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
VPTeamPage,
|
||||
VPTeamPageTitle,
|
||||
VPTeamMembers,
|
||||
VPTeamPageSection
|
||||
} from 'vitepress/theme'
|
||||
|
||||
const coreMembers = [
|
||||
{
|
||||
avatar: 'https://www.github.com/yyx990803.png',
|
||||
name: 'Evan You',
|
||||
title: 'Creator',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/yyx990803' },
|
||||
{ icon: 'twitter', link: 'https://twitter.com/youyuxi' }
|
||||
]
|
||||
},
|
||||
{
|
||||
avatar: 'https://www.github.com/yyx990803.png',
|
||||
name: 'Evan You',
|
||||
title: 'Creator',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/yyx990803' },
|
||||
{ icon: 'twitter', link: 'https://twitter.com/youyuxi' }
|
||||
]
|
||||
},
|
||||
{
|
||||
avatar: 'https://www.github.com/yyx990803.png',
|
||||
name: 'Evan You',
|
||||
title: 'Creator',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/yyx990803' },
|
||||
{ icon: 'twitter', link: 'https://twitter.com/youyuxi' }
|
||||
]
|
||||
},
|
||||
]
|
||||
const partners = [
|
||||
{
|
||||
avatar: 'https://avatars.githubusercontent.com/u/50388827?v=4',
|
||||
name: 'VanchKong',
|
||||
title: 'Translator',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/vanchKong' },
|
||||
]
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<VPTeamPage>
|
||||
<VPTeamPageTitle>
|
||||
<template #title>Our Team</template>
|
||||
<!-- <template #lead>...</template> -->
|
||||
</VPTeamPageTitle>
|
||||
<VPTeamPageSection>
|
||||
<template #title>核心成员</template>
|
||||
<template #members>
|
||||
<VPTeamMembers size="medium" :members="coreMembers" />
|
||||
</template>
|
||||
</VPTeamPageSection>
|
||||
<VPTeamPageSection>
|
||||
<template #title>合作伙伴</template>
|
||||
<!-- <template #lead>...</template> -->
|
||||
<template #members>
|
||||
<VPTeamMembers size="small" :members="partners" />
|
||||
</template>
|
||||
</VPTeamPageSection>
|
||||
</VPTeamPage>
|
||||
|
||||
<!-- <p class="red">123</p>
|
||||
|
||||
<style>
|
||||
.red {
|
||||
color: red;
|
||||
}
|
||||
</style> -->
|
||||
Loading…
Reference in new issue