Skip to content

Commit

Permalink
i18n(zh-cn): Update sidebar.mdx (#2405)
Browse files Browse the repository at this point in the history
Co-authored-by: HiDeoo <[email protected]>
  • Loading branch information
Nin3lee and HiDeoo authored Sep 25, 2024
1 parent e3fb116 commit 2ccf9ed
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions docs/src/content/docs/zh-cn/guides/sidebar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,52 @@ starlight({
在多语言网站中,`slug` 的值不会包含 URL 的语言部分。
例如,如果页面位于 `en/intro``pt-br/intro`,则在配置侧边栏时,slug 为 `intro`

### 通过徽章实现国际化

对于[徽章](#徽章)`text` 属性可以是字符串,而对于多语言网站,文本属性则可以是具有每个不同区域设置值的对象。
使用对象形式时,键必须是 [BCP-47](https://www.w3.org/International/questions/qa-choosing-language-tags) 标签(例如 `en``ar``zh-CN`):

```js {11-16}
starlight({
sidebar: [
{
label: '星座',
translations: {
'pt-BR': 'Constelações',
},
items: [
{
slug: 'constellations/andromeda',
badge: {
text: {
'zh-CN': '',
'pt-BR': 'Novo',
},
},
},
],
},
],
});
```

浏览巴西葡萄牙语文档将生成以下侧边栏:

<SidebarPreview
config={[
{
label: 'Constelações',
items: [
{
label: 'Andrômeda',
link: '',
badge: { text: 'Novo', variant: 'default' },
},
],
},
]}
/>

## 折叠分组

链接分组可以通过将 `collapsed` 属性设置为 `true` 来默认折叠。
Expand Down

0 comments on commit 2ccf9ed

Please sign in to comment.