From 90db0346718874d5eb352238a37f3cedf2b533c7 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sat, 8 Feb 2025 14:47:57 +0800 Subject: [PATCH] feat(theme): add icon support for home hero actions (#456) --- ...32\344\271\211\351\246\226\351\241\265.md" | 4 ++- .../src/client/components/Home/VPHomeHero.vue | 10 ++++++- theme/src/client/components/VPButton.vue | 27 +++++++++++++++++-- theme/src/client/globalComponents.ts | 3 +++ theme/src/node/prepare/prepareIcons.ts | 12 +++++++-- theme/src/shared/frontmatter/home.ts | 4 ++- 6 files changed, 53 insertions(+), 7 deletions(-) diff --git "a/docs/notes/theme/guide/\350\207\252\345\256\232\344\271\211\351\246\226\351\241\265.md" "b/docs/notes/theme/guide/\350\207\252\345\256\232\344\271\211\351\246\226\351\241\265.md" index 673141f8..985bb9f9 100644 --- "a/docs/notes/theme/guide/\350\207\252\345\256\232\344\271\211\351\246\226\351\241\265.md" +++ "b/docs/notes/theme/guide/\350\207\252\345\256\232\344\271\211\351\246\226\351\241\265.md" @@ -154,9 +154,11 @@ interface PlumeThemeHomeHero extends PlumeHomeConfigBase { tagline?: string text?: string actions?: { - theme?: 'brand' | 'alt' + theme?: 'brand' | 'alt' | 'sponsor' text: string link?: string + icon?: string // 文本左侧图标 + suffixIcon?: string // 文本右侧图标 target?: '_blank' | '_self' | string rel?: string } diff --git a/theme/src/client/components/Home/VPHomeHero.vue b/theme/src/client/components/Home/VPHomeHero.vue index 22303518..982276e8 100644 --- a/theme/src/client/components/Home/VPHomeHero.vue +++ b/theme/src/client/components/Home/VPHomeHero.vue @@ -68,6 +68,8 @@ useHomeHeroTintPlate( :href="action.link" :target="action.target" :rel="action.rel" + :icon="action.icon" + :suffix-icon="action.suffixIcon" /> @@ -168,8 +170,14 @@ useHomeHeroTintPlate( margin: 30px 0 0; } +.action { + display: flex; + gap: 24px; + align-items: center; +} + .action :deep(.vp-button) { - margin-right: 24px; + margin-left: 0; } .action :deep(.vp-button:last-of-type) { diff --git a/theme/src/client/components/VPButton.vue b/theme/src/client/components/VPButton.vue index 75d282cd..6a6c4d6f 100644 --- a/theme/src/client/components/VPButton.vue +++ b/theme/src/client/components/VPButton.vue @@ -1,4 +1,5 @@