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 reference/icons.mdx & components/icons.mdx & using-components.mdx #2817

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/src/content/docs/zh-cn/components/icons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import { Icon } from '@astrojs/starlight/components';
### `name`

**必要属性**
**类型:** `string`
**类型:** [`StarlightIcon`](/zh-cn/reference/icons/#starlighticon-类型)

要显示的图标名称设置为 [Starlight 的内置图标之一](/zh-cn/reference/icons/#所有图标)。

Expand Down
6 changes: 3 additions & 3 deletions docs/src/content/docs/zh-cn/components/using-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ Starlight 将默认样式应用于 Markdown 内容,例如,在元素之间添
使用 `astro/types` 中的 [`ComponentProps`](https://docs.astro.build/zh-cn/guides/typescript/#componentprops-类型) 类型来引用组件接受的 `Props`,即使它们不是由组件本身导出的。
这在包装或扩展现有组件时非常有用。

以下示例为,使用 `ComponentProps` 获取 Starlight 内置 `Icon` 组件接受的 props 类型:
以下示例为,使用 `ComponentProps` 获取 Starlight 内置 `Badge` 组件接受的 props 类型:

```astro
---
// src/components/Example.astro
import type { ComponentProps } from 'astro/types';
import { Icon } from '@astrojs/starlight/components';
import { Badge } from '@astrojs/starlight/components';

type IconProps = ComponentProps<typeof Icon>;
type BadgeProps = ComponentProps<typeof Badge>;
---
```
13 changes: 13 additions & 0 deletions docs/src/content/docs/zh-cn/reference/icons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ Starlight 提供了一组内置图标,你可以使用 `<Icon>` 组件在内容
可以使用 [`<Icon>`](/zh-cn/components/icons/) 组件来显示图标。
图标也常用于其他组件,例如 [卡片](/zh-cn/components/cards/) 或 [hero actions](/zh-cn/reference/frontmatter/#hero) 等设置。

## `StarlightIcon` 类型

使用 `StarlightIcon` TypeScript 类型来引用 [Starlight 的内置图标的名称](#所有图标)。

```ts {2} /icon: (StarlightIcon)/
// src/icon.ts
import type { StarlightIcon } from '@astrojs/starlight/types';

function getIconLabel(icon: StarlightIcon) {
// …
}
```

## 所有图标

下面显示了所有可用图标,包括它们对应名称的列表。单击图标将其名称复制到剪贴板。
Expand Down
Loading