File tree 4 files changed +58
-3
lines changed
4 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,42 @@ Wraps in a <div class="vp-raw">
263
263
})
264
264
```
265
265
266
+ ## GitHub 风格的警报 {#github-flavored-alerts}
267
+
268
+ VitePress 同样支持以标注的方式渲染 [ GitHub 风格的警报] ( https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts ) 。它们和[ 自定义容器] ( #custom-containers ) 的渲染方式相同。
269
+
270
+ ``` md
271
+ > [!NOTE]
272
+ > Highlights information that users should take into account, even when skimming.
273
+
274
+ > [!TIP]
275
+ > Optional information to help a user be more successful.
276
+
277
+ > [!IMPORTANT]
278
+ > Crucial information necessary for users to succeed.
279
+
280
+ > [!WARNING]
281
+ > Critical content demanding immediate user attention due to potential risks.
282
+
283
+ > [!CAUTION]
284
+ > Negative potential consequences of an action.
285
+ ```
286
+
287
+ > [ !NOTE]
288
+ > Highlights information that users should take into account, even when skimming.
289
+
290
+ > [ !TIP]
291
+ > Optional information to help a user be more successful.
292
+
293
+ > [ !IMPORTANT]
294
+ > Crucial information necessary for users to succeed.
295
+
296
+ > [ !WARNING]
297
+ > Critical content demanding immediate user attention due to potential risks.
298
+
299
+ > [ !CAUTION]
300
+ > Negative potential consequences of an action.
301
+
266
302
## 代码块中的语法高亮 {#syntax-highlighting-in-code-blocks}
267
303
268
304
VitePress 使用 [ Shikiji] ( https://github.com/antfu/shikiji ) ([ Shiki] ( https://shiki.matsu.io/ ) 的改进版本) 在 Markdown 代码块中使用彩色文本实现语法高亮。Shiki 支持多种编程语言。需要做的就是将有效的语言别名附加到代码块的开头:
Original file line number Diff line number Diff line change @@ -129,17 +129,17 @@ src/getting-started.md --> /getting-started.html
129
129
130
130
默认情况下,VitePress 将入站链接解析为以 ` .html ` 结尾的 URL。但是,一些用户可能更喜欢没有 .html 扩展名的“简洁 URL”——例如,` example.com/path ` 而不是 ` example.com/path.html ` 。
131
131
132
- 某些服务器或托管平台 (例如 Netlify 或 Vercel ) 提供将 ` /foo ` 之类的 URL 映射到 ` /foo.html ` (如果存在) 的功能,而无需重定向:
132
+ 某些服务器或托管平台 (例如 Netlify、Vercel 或 GitHub Pages ) 提供将 ` /foo ` 之类的 URL 映射到 ` /foo.html ` (如果存在) 的功能,而无需重定向:
133
133
134
- - Netlify 默认支持 。
134
+ - Netlify 和 GitHub Pages 是默认支持的 。
135
135
- Vercel 需要在 [ vercel.json 中启用 cleanUrls 选项] ( https://vercel.com/docs/concepts/projects/project-configuration#cleanurls ) 。
136
136
137
137
如果可以使用此功能,还可以启用 VitePress 自己的 [ ` cleanUrls ` ] ( ../reference/site-config#cleanurls ) 配置选项,以便:
138
138
139
139
- 页面之间的入站链接是在没有 ` .html ` 扩展名的情况下生成的。
140
140
- 如果当前路径以 ` .html ` 结尾,路由器将执行客户端重定向到无扩展路径。
141
141
142
- 但是,如果无法为服务器配置此类支持 (例如 GitHub Pages) ,则必须手动采用以下目录结构:
142
+ 但是,如果无法为服务器配置此类支持,则必须手动采用以下目录结构:
143
143
144
144
```
145
145
.
Original file line number Diff line number Diff line change @@ -244,6 +244,7 @@ type SocialLinkIcon =
244
244
| ' instagram'
245
245
| ' linkedin'
246
246
| ' mastodon'
247
+ | ' npm'
247
248
| ' slack'
248
249
| ' twitter'
249
250
| ' x'
Original file line number Diff line number Diff line change @@ -645,6 +645,24 @@ export default {
645
645
}
646
646
```
647
647
648
+ #### 示例:添加 canonical URL ` <link> ` {#example-adding-a-canonical-url-link}
649
+
650
+ ``` ts
651
+ export default {
652
+ transformPageData(pageData ) {
653
+ const canonicalUrl = ` https://example.com/${pageData .relativePath } `
654
+ .replace (/ index\. md$ / , ' ' )
655
+ .replace (/ \. md$ / , ' .html' )
656
+
657
+ pageData .frontmatter .head ?? = []
658
+ pageData .frontmatter .head .push ([
659
+ ' link' ,
660
+ { rel: ' canonical' , href: canonicalUrl }
661
+ ])
662
+ }
663
+ }
664
+ ```
665
+
648
666
### transformHtml
649
667
650
668
- 类型:` (code: string, id: string, context: TransformContext) => Awaitable<string | void> `
You can’t perform that action at this time.
0 commit comments