Files
hextra_mirror/exampleSite/content/docs/guide/shortcodes/cards.zh-cn.md
Xin ec007d73c0 docs(blog): prepare for v0.10 release post (#746)
* docs(blog): prepare for v0.10 release post

* Update v0.10.md

* Update v0.10.md to refine upgrade instructions and enhance blog features. Added synchronized tab switching and pagination controls, while improving the search experience and table of contents navigation.

* Enhance v0.10 release documentation with detailed upgrade instructions and migration guide. Added Tailwind theme variable customization section and clarified breaking changes. Improved clarity on CSS class prefix changes for better user experience.

* Update v0.10.md to enhance upgrade instructions, clarify breaking changes, and improve overall readability. Adjusted formatting for consistency and added details on asset management and user experience improvements.

* Add notable new features to v0.10.md, including dropdown menu support, enhanced search experience, and blog list pagination. Updated FlexSearch upgrade details for clarity and improved migration guide by removing redundant breaking change notes.

* chore: update zh-cn translation

* chore: update ja translation

* chore: update fa and ja translations

* chore: prepare release
2025-08-14 23:49:06 +08:00

4.9 KiB
Raw Blame History

title, linkTitle
title linkTitle
卡片组件 卡片

示例

{{< cards >}} {{< card link="../callout" title="提示框" icon="warning" >}} {{< card link="../callout" title="带标签的卡片" icon="tag" tag="自定义标签">}} {{< card link="/" title="无图标" >}} {{< /cards >}}

{{< cards >}} {{< card link="/" title="图片卡片" image="https://github.com/user-attachments/assets/71b7e3ec-1a8d-4582-b600-5425c6cc0407" subtitle="网络图片" >}} {{< card link="/" title="本地图片" image="/images/card-image-unprocessed.jpg" subtitle="静态目录下的原始图片。" >}} {{< card link="/" title="本地图片" image="images/space.jpg" subtitle="资源目录下的图片经过Hugo处理。" method="Resize" options="600x q80 webp" >}} {{< /cards >}}

使用方法

{{</* cards */>}}
  {{</* card link="../callout" title="提示框" icon="warning" */>}}
  {{</* card link="../callout" title="带标签的卡片" icon="tag" tag= "自定义标签" */>}}
  {{</* card link="/" title="无图标" */>}}
{{</* /cards */>}}
{{</* cards */>}}
  {{</* card link="/" title="图片卡片" image="https://source.unsplash.com/featured/800x600?landscape" subtitle="Unsplash风景图" */>}}
  {{</* card link="/" title="本地图片" image="/images/card-image-unprocessed.jpg" subtitle="静态目录下的原始图片。" */>}}
  {{</* card link="/" title="本地图片" image="images/space.jpg" subtitle="资源目录下的图片经过Hugo处理。" method="Resize" options="600x q80 webp" */>}}
{{</* /cards */>}}

卡片参数

参数 描述
link 链接地址(内部或外部)。
title 卡片的标题。
subtitle 卡片的副标题支持Markdown
icon 图标名称。
tag 标签文本。
tagColor 标签颜色:gray(默认)、yellowredblue

图片卡片

此外,卡片还支持通过以下参数添加图片并进行处理:

参数 描述
image 指定卡片的图片URL。
method 设置Hugo的图片处理方法。
options 配置Hugo的图片处理选项。

卡片支持三种类型的图片:

  1. 远程图片:在image参数中填写完整的URL。
  2. 静态图片使用Hugo的static/目录下的相对路径。
  3. 处理后的图片使用Hugo的assets/目录下的相对路径。

Hextra在构建时会自动检测是否需要图片处理并应用options参数或默认设置Resize800x质量80WebP格式。 目前支持的method有:ResizeFitFillCrop

有关Hugo内置图片处理命令、方法和选项的更多信息请参阅其图片处理文档

标签

卡片支持添加标签,可用于显示额外的状态信息。

{{< cards >}} {{< card link="../callout" title="带默认标签的卡片" tag="标签文本" >}} {{< card link="../callout" title="带错误标签的卡片" tag="标签文本" tagType="error" >}} {{< card link="../callout" title="带信息标签的卡片" tag="标签文本" tagType="info" >}} {{< card link="../callout" title="带警告标签的卡片" tag="标签文本" tagType="warning" >}} {{< card link="/" title="图片卡片" image="https://github.com/user-attachments/assets/71b7e3ec-1a8d-4582-b600-5425c6cc0407" subtitle="网络图片" tag="标签文本" tagType="error" >}} {{< /cards >}}

{{</* cards */>}}
  {{</* card link="../callout" title="带默认标签颜色的卡片" tag="标签文本" */>}}
  {{</* card link="../callout" title="带红色标签的卡片" tag="标签文本" tagType="error" */>}}
  {{</* card link="../callout" title="带蓝色标签的卡片" tag="标签文本" tagType="info" */>}}
  {{</* card link="../callout" title="带黄色标签的卡片" tag="标签文本" tagType="warning" */>}}
{{</* /cards */>}}

列数

可以通过向cards短代码传递cols参数来指定卡片的最大列数。请注意,在小屏幕上列数仍会折叠。

{{< cards cols="1" >}} {{< card link="/" title="顶部卡片" >}} {{< card link="/" title="底部卡片" >}} {{< /cards >}}

{{< cards cols="2" >}} {{< card link="/" title="左侧卡片" >}} {{< card link="/" title="右侧卡片" >}} {{< /cards >}}

{{</* cards cols="1" */>}}
  {{</* card link="/" title="顶部卡片" */>}}
  {{</* card link="/" title="底部卡片" */>}}
{{</* /cards */>}}

{{</* cards cols="2" */>}}
  {{</* card link="/" title="左侧卡片" */>}}
  {{</* card link="/" title="右侧卡片" */>}}
{{</* /cards */>}}