Skip to content

Commit

Permalink
i18n(zh-cn): Update reference/icons.mdx & components/icons.mdx & …
Browse files Browse the repository at this point in the history
…`using-components.mdx` (#2817)
  • Loading branch information
Nin3lee authored Jan 21, 2025
1 parent 8885bf5 commit 66a4131
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
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

0 comments on commit 66a4131

Please sign in to comment.