mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
de7c87a2c1
Co-authored-by: locadex-agent[bot] <217277504+locadex-agent[bot]@users.noreply.github.com>
99 lines
2.8 KiB
Plaintext
99 lines
2.8 KiB
Plaintext
---
|
||
title: "横幅"
|
||
description: "添加横幅以显示全站重要公告和通知。"
|
||
keywords: ["banner", "announcements", "site-wide"]
|
||
---
|
||
|
||
使用横幅在整个文档站点显示重要公告、更新或通知。横幅会显示在每个页面顶部,支持 Markdown 格式,并可设置为可关闭。横幅使用你的 `docs.json` 中 `colors.dark` 属性定义的颜色。
|
||
|
||
要添加横幅,请在你的 `docs.json` 中使用 `banner` 属性:
|
||
|
||
<CodeGroup>
|
||
```json Product announcements wrap
|
||
"banner": {
|
||
"content": "🚀 2.0 版本现已上线!查看我们的[更新日志](/changelog)了解详情。",
|
||
"dismissible": true
|
||
}
|
||
```
|
||
|
||
```json Maintenance notices wrap
|
||
"banner": {
|
||
"content": "⚠️ 计划维护:API 将于 12 月 15 日 02:00–04:00(UTC)不可用",
|
||
"dismissible": false
|
||
}
|
||
```
|
||
|
||
```json Required actions wrap
|
||
"banner": {
|
||
"content": "**需要操作:** 请在 1 月 1 日前迁移到我们的新版本。[迁移指南](/migration)",
|
||
"dismissible": true
|
||
}
|
||
```
|
||
</CodeGroup>
|
||
|
||
<div id="properties">
|
||
## 属性
|
||
</div>
|
||
|
||
<ResponseField name="content" type="string" required>
|
||
横幅文案。支持纯文本和 Markdown 格式。
|
||
</ResponseField>
|
||
|
||
<ResponseField name="dismissible" type="boolean">
|
||
是否允许用户关闭横幅。为 `true` 时,用户可将其关闭,且在当前会话内不会再次出现。默认值为 `false`。
|
||
</ResponseField>
|
||
|
||
<div id="language-specific-banners">
|
||
## 语言特定横幅
|
||
</div>
|
||
|
||
在文档中为每种语言配置不同的横幅内容。在 `docs.json` 的 `navigation.languages` 数组中定义语言特定的横幅。
|
||
|
||
```json
|
||
{
|
||
"navigation": {
|
||
"languages": [
|
||
{
|
||
"language": "en",
|
||
"banner": {
|
||
"content": "🚀 Version 2.0 is now live! See our [changelog](/en/changelog) for details.",
|
||
"dismissible": true
|
||
},
|
||
"groups": [
|
||
{
|
||
"group": "Getting started",
|
||
"pages": ["en/overview", "en/quickstart"]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"language": "es",
|
||
"banner": {
|
||
"content": "🚀 ¡La versión 2.0 ya está disponible! Consulta nuestro [registro de cambios](/es/changelog) para más detalles.",
|
||
"dismissible": true
|
||
},
|
||
"groups": [
|
||
{
|
||
"group": "Getting started",
|
||
"pages": ["es/overview", "es/quickstart"]
|
||
}
|
||
]
|
||
}
|
||
]
|
||
},
|
||
"banner": {
|
||
"content": "🚀 Version 2.0 is now live!",
|
||
"dismissible": true
|
||
}
|
||
}
|
||
```
|
||
|
||
|
||
<div id="fallback-behavior">
|
||
### 回退行为
|
||
</div>
|
||
|
||
横幅在确定要显示哪个内容时遵循以下优先顺序:
|
||
|
||
1. **特定语言横幅**:如果当前语言有 `banner` 配置,则以该配置为准。
|
||
2. **全局横幅**:如果不存在特定语言横幅,则显示全局 `banner`。 |