Appearance
Markdown 扩展
VitePress 带有内置的 Markdown 扩展。
标题锚点
标题会自动应用锚点。可以使用 markdown.anchor 选项配置锚点的渲染。
自定义锚点
要为标题指定自定义锚点而不是使用自动生成的锚点,请向标题添加后缀:
# 使用自定义锚点 {#my-anchor}这允许将标题链接为 #my-anchor,而不是默认的 #使用自定义锚点。
链接
内部和外部链接都会被特殊处理。
内部链接
内部链接将转换为单页导航的路由链接。此外,子目录中包含的每个 index.md 都会自动转换为 index.html,并带有相应的 URL /。
例如,给定以下目录结构:
.
├─ index.md
├─ foo
│ ├─ index.md
│ ├─ one.md
│ └─ two.md
└─ bar
├─ index.md
├─ three.md
└─ four.md假设现在处于 foo/one.md 文件中:
md
[Home](/) <!-- 将用户导航至根目录下的 index.html -->
[foo](/foo/) <!-- 将用户导航至目录 foo 下的 index.html -->
[foo heading](./#heading) <!-- 将用户锚定到目录 foo 下的index文件中的一个标题上 -->
[bar - three](../bar/three) <!-- 可以省略扩展名 -->
[bar - three](../bar/three.md) <!-- 可以添加 .md -->
[bar - four](../bar/four.html) <!-- 或者可以添加 .html -->页面后缀
默认情况下,生成的页面和内部链接带有 .html 后缀。
外部链接
外部链接带有 target="_blank" rel="noreferrer":
frontmatter
YAML 格式的 frontmatter 开箱即用:
yaml
---
title: Blogging Like a Hacker
lang: en-US
---此数据将可用于页面的其余部分,以及所有自定义和主题组件。
更多信息,参见 frontmatter。
GitHub 风格的表格
输入
| Tables | Are | Cool |
| ------------- | :-----------: | ----: |
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |输出
| Tables | Are | Cool |
|---|---|---|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
Emoji 🎉
输入
:tada: :100:输出
🎉 💯
这里可以找到所有支持的 emoji 列表。
目录表 (TOC)
输入
[[toc]]输出
可以使用 markdown.toc 选项配置 TOC 的呈现效果。
自定义容器
自定义容器可以通过它们的类型、标题和内容来定义。
默认标题
输入
md
::: info
This is an info box.
:::
::: tip
This is a tip.
:::
::: warning
This is a warning.
:::
::: danger
This is a dangerous warning.
:::
::: details
This is a details block.
:::输出
INFO
This is an info box.
TIP
This is a tip.
WARNING
This is a warning.
DANGER
This is a dangerous warning.
Details
This is a details block.
自定义标题
可以通过在容器的 "type" 之后附加文本来设置自定义标题。
输入
md
::: danger STOP
危险区域,请勿继续
:::
::: details 点我查看代码
```js
console.log('Hello, VitePress!')
```
:::输出
STOP
危险区域,请勿继续
点我查看代码
js
console.log('Hello, VitePress!')请查看配置参考:站点配置来获取完整的可配置属性列表。