From a85bb22336a0d7d599108383fdfe8ef43f47b50a Mon Sep 17 00:00:00 2001 From: liruifengv Date: Sun, 28 Sep 2025 20:51:20 +0800 Subject: [PATCH] i18n(zh-cn): Update `images.mdx` --- src/content/docs/zh-cn/guides/images.mdx | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/content/docs/zh-cn/guides/images.mdx b/src/content/docs/zh-cn/guides/images.mdx index 1f7baa4a6dfb8..a528cfa45b16b 100644 --- a/src/content/docs/zh-cn/guides/images.mdx +++ b/src/content/docs/zh-cn/guides/images.mdx @@ -432,6 +432,33 @@ import Logo from '../assets/logo.svg'; ``` +#### `SvgComponent` 类型 + + + +你也可以使用 `SvgComponent` 类型对 `.svg` 资源强制实施类型安全: + +```astro title="src/components/Logo.astro" +--- +import type { SvgComponent } from "astro/types"; +import HomeIcon from './Home.svg' + +interface Link { + url: string + text: string + icon: SvgComponent +} + +const links: Link[] = [ + { + url: '/', + text: 'Home', + icon: HomeIcon + } +] +--- +``` + ### 创建自定义图像组件 你可以通过将 `` 或 `` 组件包装在另一个 Astro 组件中来创建自定义、可重用的图像组件。这允许你只设置一次默认属性和样式。