diff options
author | Nin3 | 2025-01-21 19:04:44 +0800 |
---|---|---|
committer | GitHub | 2025-01-21 12:04:44 +0100 |
commit | 66a4131c63ec8ff425c6f04c1c496abbdfddc945 (patch) | |
tree | ebfd8cc9d94fb37533d3ccd19c93da4fbd4ce27b | |
parent | 8885bf598cd9c2c0646022279c58ec1a7056c1a1 (diff) | |
download | IT.starlight-66a4131c63ec8ff425c6f04c1c496abbdfddc945.tar.gz IT.starlight-66a4131c63ec8ff425c6f04c1c496abbdfddc945.tar.bz2 IT.starlight-66a4131c63ec8ff425c6f04c1c496abbdfddc945.zip |
i18n(zh-cn): Update `reference/icons.mdx` & `components/icons.mdx` & `using-components.mdx` (#2817)
-rw-r--r-- | docs/src/content/docs/zh-cn/components/icons.mdx | 2 | ||||
-rw-r--r-- | docs/src/content/docs/zh-cn/components/using-components.mdx | 6 | ||||
-rw-r--r-- | docs/src/content/docs/zh-cn/reference/icons.mdx | 13 |
3 files changed, 17 insertions, 4 deletions
diff --git a/docs/src/content/docs/zh-cn/components/icons.mdx b/docs/src/content/docs/zh-cn/components/icons.mdx index bd425fc4..b0121d59 100644 --- a/docs/src/content/docs/zh-cn/components/icons.mdx +++ b/docs/src/content/docs/zh-cn/components/icons.mdx @@ -95,7 +95,7 @@ import { Icon } from '@astrojs/starlight/components'; ### `name` **必要属性** -**类型:** `string` +**类型:** [`StarlightIcon`](/zh-cn/reference/icons/#starlighticon-类型) 要显示的图标名称设置为 [Starlight 的内置图标之一](/zh-cn/reference/icons/#所有图标)。 diff --git a/docs/src/content/docs/zh-cn/components/using-components.mdx b/docs/src/content/docs/zh-cn/components/using-components.mdx index 05108e9c..7aeacfc0 100644 --- a/docs/src/content/docs/zh-cn/components/using-components.mdx +++ b/docs/src/content/docs/zh-cn/components/using-components.mdx @@ -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>; --- ``` diff --git a/docs/src/content/docs/zh-cn/reference/icons.mdx b/docs/src/content/docs/zh-cn/reference/icons.mdx index fcf9541d..11701a82 100644 --- a/docs/src/content/docs/zh-cn/reference/icons.mdx +++ b/docs/src/content/docs/zh-cn/reference/icons.mdx @@ -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) { + // … +} +``` + ## 所有图标 下面显示了所有可用图标,包括它们对应名称的列表。单击图标将其名称复制到剪贴板。 |