Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n(zh-cn): Update sidebar.mdx #2405

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading