From 6e742c4e9514b9ee31105e25d1ad1387b9f81b56 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:02:12 +0100 Subject: [PATCH] feat: parameterize hardcoded icon references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add [params.icons] section to config.toml with defaults for carouselPrev, carouselNext, ctaAction, and preview device/error icons - Read icons from site.Params.icons.* in testimonial-carousel.html, preview.html, page/contact.html, and cta.hugo.html - Preserve fa-2xl and fa-fw suffix modifiers when building icon strings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- component-library/components/cta/cta.hugo.html | 3 ++- config.toml | 13 +++++++++++++ layouts/partials/assets/preview.html | 11 ++++++++--- layouts/partials/assets/testimonial-carousel.html | 6 ++++-- layouts/partials/page/contact.html | 3 ++- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/component-library/components/cta/cta.hugo.html b/component-library/components/cta/cta.hugo.html index 88a71f7..62af951 100644 --- a/component-library/components/cta/cta.hugo.html +++ b/component-library/components/cta/cta.hugo.html @@ -10,12 +10,13 @@ */}} {{/* Main code */}} +{{- $ctaAction := site.Params.icons.ctaAction | default "fas chevron-right" -}} {{ $links := slice }} {{ if and (reflect.IsSlice .links) (gt (len .links) 0) }} {{ $links = .links }} {{ else }} {{ with site.Params.modules.bookshop.cta.defaultURL }} - {{ $links = $links | append (dict "title" (T "contactAction") "url" . "icon" "fas chevron-right") }} + {{ $links = $links | append (dict "title" (T "contactAction") "url" . "icon" $ctaAction) }} {{ end }} {{ end }} diff --git a/config.toml b/config.toml index 6d1da60..054e910 100644 --- a/config.toml +++ b/config.toml @@ -51,6 +51,19 @@ [[module.imports]] path = "github.com/cloudcannon/bookshop/hugo/v3" +# Icon defaults for mod-blocks components +[params.icons] + # Testimonial carousel controls + carouselPrev = "fas chevron-left" + carouselNext = "fas chevron-right" + # CTA and contact action links + ctaAction = "fas chevron-right" + # Preview component device tabs and error state + previewDesktop = "fas fa-desktop" + previewTablet = "fas fa-tablet-alt" + previewMobile = "fas fa-mobile-alt" + previewError = "fas fa-exclamation-triangle" + # Bookshop module configuration # These defaults are used by mod-blocks components [params.modules.bookshop] diff --git a/layouts/partials/assets/preview.html b/layouts/partials/assets/preview.html index 9cdd863..3f1c080 100644 --- a/layouts/partials/assets/preview.html +++ b/layouts/partials/assets/preview.html @@ -21,6 +21,12 @@ {{/* Initialize global variables */}} {{- $padding := partial "utilities/GetPadding.html" -}} +{{- $deviceIcons := dict + "desktop" (site.Params.icons.previewDesktop | default "fas fa-desktop") + "tablet" (site.Params.icons.previewTablet | default "fas fa-tablet-alt") + "mobile" (site.Params.icons.previewMobile | default "fas fa-mobile-alt") +-}} +{{- $previewError := site.Params.icons.previewError | default "fas fa-exclamation-triangle" -}} {{/* Initialize local variables */}} {{- $devices := slice "desktop" "tablet" "mobile" -}} @@ -41,7 +47,6 @@
{{- range $index, $device := $devices -}} {{- $isActive := eq $device $defaultDevice -}} - {{- $iconName := cond (eq $device "desktop") "desktop" (cond (eq $device "tablet") "tablet-alt" "mobile-alt") -}} {{- end -}}
@@ -76,7 +81,7 @@ diff --git a/layouts/partials/page/contact.html b/layouts/partials/page/contact.html index 984f69b..ab77a09 100644 --- a/layouts/partials/page/contact.html +++ b/layouts/partials/page/contact.html @@ -3,6 +3,7 @@ {{- $orientation := .orientation -}} {{- $align := .align | default "start" }} {{- $title := .title | default (T "contactHeaderTopic") }} +{{- $ctaAction := site.Params.icons.ctaAction | default "fas chevron-right" -}} {{- with $contact -}} {{- $link := "" -}} @@ -19,7 +20,7 @@ "orientation" $orientation "class" "contact-img" "contact" $contact - "links" (slice (dict "title" (T "contactAction") "url" $link "icon" "fas chevron-right")) + "links" (slice (dict "title" (T "contactAction") "url" $link "icon" $ctaAction)) "data" site.Params.modules.bookshop.cta.section ) }} {{ else }}