From 408d9f1acb9f67afcbf0654b82667a0d36ffae9e Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Sat, 28 Mar 2026 12:50:32 +0100 Subject: [PATCH 1/2] feat: add heading component Adds a new Bookshop heading component that renders a section heading with optional preheading, title, and content using section-title partial. Co-Authored-By: Claude Sonnet 4.6 --- component-library/bookshop.scss | 1 + .../components/heading/heading.bookshop.yml | 33 ++++++++++ .../components/heading/heading.hugo.html | 62 +++++++++++++++++++ .../components/heading/heading.hugo.md | 1 + .../components/heading/heading.scss | 0 .../components/heading/heading.yml | 7 +++ 6 files changed, 104 insertions(+) create mode 100644 component-library/components/heading/heading.bookshop.yml create mode 100644 component-library/components/heading/heading.hugo.html create mode 100644 component-library/components/heading/heading.hugo.md create mode 100644 component-library/components/heading/heading.scss create mode 100644 component-library/components/heading/heading.yml diff --git a/component-library/bookshop.scss b/component-library/bookshop.scss index 41631e1..0765909 100644 --- a/component-library/bookshop.scss +++ b/component-library/bookshop.scss @@ -6,6 +6,7 @@ @import "modules/bookshop/components/cta/cta"; @import "modules/bookshop/components/faq/faq"; @import "modules/bookshop/components/featured/featured"; +@import "modules/bookshop/components/heading/heading"; @import "modules/bookshop/components/hero/hero"; @import "modules/bookshop/components/list/list"; @import "modules/bookshop/components/menu/menu"; diff --git a/component-library/components/heading/heading.bookshop.yml b/component-library/components/heading/heading.bookshop.yml new file mode 100644 index 0000000..19f1d89 --- /dev/null +++ b/component-library/components/heading/heading.bookshop.yml @@ -0,0 +1,33 @@ +# Metadata about this component, to be used in the CMS +spec: + structures: + - content_blocks + label: Heading + description: Show a section heading with regular content + icon: title + tags: [] + +# Defines the structure of this component, as well as the default values +blueprint: + heading: + preheading: + title: + content: + align: start + arrangement: + width: + size: + background: + backdrop: + color: + subtle: + class: + width: + justify: start + wrapper: + fluid: + theme: + cover: + overlay_mode: + section_class: + bg_class: diff --git a/component-library/components/heading/heading.hugo.html b/component-library/components/heading/heading.hugo.html new file mode 100644 index 0000000..895a99d --- /dev/null +++ b/component-library/components/heading/heading.hugo.html @@ -0,0 +1,62 @@ +{{/* + Copyright © 2026 The Hinode Team / Mark Dumay. All rights reserved. + Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file. + Visit gethinode.com/license for more details. + + Note: To support live editing, bookshop components should use a clear path to the provided arguments. + Therefore, we cannot use the InitArgs partial at this point, and we need to access each argument + directly. See the docs for more background: + https://github.com/CloudCannon/bookshop/blob/main/guides/hugo.adoc#passing-data-to-bookshop-components +*/}} + +{{/* Validate arguments */}} +{{ $error := false }} +{{ if not site.Params.env_bookshop_live }} + {{ $args := partial "utilities/InitArgs.html" (dict "bookshop" "heading" "args" .) }} + {{ if or $args.err $args.warnmsg }} + {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict + "partial" "component-library/components/heading/heading.hugo.html" + "warnid" "warn-invalid-arguments" + "msg" "Invalid arguments" + "details" ($args.errmsg | append $args.warnmsg) + "file" page.File + )}} + {{ $error = $args.err }} + {{- end -}} +{{- end -}} + +{{ if not $error }} + {{/* Initialize global arguments */}} + {{- $padding := partial "utilities/GetPadding.html" -}} + + {{/* Capture common class settting */}} + {{ $settings := dict }} + {{ if reflect.IsMap site.Params.modules.blocks }} + {{ $settings = index site.Params.modules.blocks "heading" }} + {{ end }} + {{ $class := index $settings "class" | default "" }} + + {{/* Main code */}} + {{- $raw := partial "assets/section-title.html" (dict + "heading" .heading + "justify" .justify) + -}} + + {{ if $raw }} + {{ partial "utilities/section.html" (dict + "component-name" "heading" + "id" .id + "raw" $raw + "background" .background + "width" .width + "justify" .justify + "wrapper" .wrapper + "fluid" .fluid + "theme" .theme + "cover" .cover + "overlay-mode" (or .overlay_mode (index . "overlay-mode")) + "section-class" (or .section_class (index . "section-class")) + "bg-class" (or .bg_class (index . "bg-class")) + )}} + {{ end }} +{{ end }} diff --git a/component-library/components/heading/heading.hugo.md b/component-library/components/heading/heading.hugo.md new file mode 100644 index 0000000..54ba48f --- /dev/null +++ b/component-library/components/heading/heading.hugo.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/component-library/components/heading/heading.scss b/component-library/components/heading/heading.scss new file mode 100644 index 0000000..e69de29 diff --git a/component-library/components/heading/heading.yml b/component-library/components/heading/heading.yml new file mode 100644 index 0000000..9a6d993 --- /dev/null +++ b/component-library/components/heading/heading.yml @@ -0,0 +1,7 @@ +comment: >- + Renders a section heading with optional regular content. +example: | + heading: + preheading: Preheading + title: Section heading + content: Regular content that is placed below the title. From 6e32342487dfd9289e64878c66276e0e46381fbc Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Sat, 28 Mar 2026 12:52:09 +0100 Subject: [PATCH 2/2] feat(separator): add clear separator variant and class/id support Adds a clear (invisible) separator variant using a div with padding, and support for id, section_class, and custom styling via scss. Co-Authored-By: Claude Sonnet 4.6 --- .../components/separator/separator.bookshop.yml | 1 + .../components/separator/separator.hugo.html | 14 +++++++++++++- .../components/separator/separator.scss | 3 +++ exampleSite/go.mod | 4 ++-- exampleSite/go.sum | 4 ++++ go.mod | 2 +- go.sum | 2 ++ 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/component-library/components/separator/separator.bookshop.yml b/component-library/components/separator/separator.bookshop.yml index 6d80277..355e999 100644 --- a/component-library/components/separator/separator.bookshop.yml +++ b/component-library/components/separator/separator.bookshop.yml @@ -8,5 +8,6 @@ spec: tags: [] blueprint: + clear: section_class: bg_class: diff --git a/component-library/components/separator/separator.hugo.html b/component-library/components/separator/separator.hugo.html index 213b242..f2a760b 100644 --- a/component-library/components/separator/separator.hugo.html +++ b/component-library/components/separator/separator.hugo.html @@ -6,6 +6,9 @@ {{/* Validate arguments */}} {{ $error := false }} +{{ $id := .id }} +{{ $clear := .clear }} +{{ $class := .section_class }} {{ if not site.Params.env_bookshop_live }} {{ $args := partial "utilities/InitArgs.html" (dict "bookshop" "separator" "args" .) }} {{ if or $args.err $args.warnmsg }} @@ -17,9 +20,18 @@ "file" page.File )}} {{ $error = $args.err }} + {{ else }} + {{ $id = $args.id }} + {{ $clear = $args.clear }} + {{ $class = $args.section_class }} {{- end -}} {{- end -}} {{ if not $error }} -
+ {{ if $clear }} + {{- $padding := partial "utilities/GetPadding.html" -}} +
+ {{ else }} +
+ {{ end }} {{ end }} diff --git a/component-library/components/separator/separator.scss b/component-library/components/separator/separator.scss index e69de29..e22d08a 100644 --- a/component-library/components/separator/separator.scss +++ b/component-library/components/separator/separator.scss @@ -0,0 +1,3 @@ +.clear-separator { + border: none; +} diff --git a/exampleSite/go.mod b/exampleSite/go.mod index 490fe20..428fa8d 100644 --- a/exampleSite/go.mod +++ b/exampleSite/go.mod @@ -4,6 +4,6 @@ go 1.19 require ( github.com/cloudcannon/bookshop/hugo/v3 v3.18.2 // indirect - github.com/gethinode/mod-blocks v1.15.2 // indirect - github.com/gethinode/mod-utils/v5 v5.19.1 // indirect + github.com/gethinode/mod-blocks v1.15.3 // indirect + github.com/gethinode/mod-utils/v5 v5.20.0 // indirect ) diff --git a/exampleSite/go.sum b/exampleSite/go.sum index 8de7263..a40ad36 100644 --- a/exampleSite/go.sum +++ b/exampleSite/go.sum @@ -56,6 +56,8 @@ github.com/gethinode/mod-blocks v1.15.1 h1:gKUclJD+yUhsrLRr5uheOJ2MMLK2EuAAZFZI6 github.com/gethinode/mod-blocks v1.15.1/go.mod h1:A9WagW9TCZxv/VsVF92CATjfxeVDKBrhF1n33IV9250= github.com/gethinode/mod-blocks v1.15.2 h1:Sx1HdveBvJuQlTw1rfKwW4nkVZfJuien+6CykLGvo90= github.com/gethinode/mod-blocks v1.15.2/go.mod h1:iG/4tXktwqgUyzHyRbuAHmGsdQwmEhUG/YkufNcUe+k= +github.com/gethinode/mod-blocks v1.15.3 h1:GORSj6ehAGuOTBKvXSGiy8EuCx5hnbEJvgVoW4gIDEg= +github.com/gethinode/mod-blocks v1.15.3/go.mod h1:jX1qXECc+RNBiGE9lOhc+5QE7JvCBWL1m/dzY2F6Dx4= github.com/gethinode/mod-utils/v5 v5.10.0 h1:NlofAfa1YILV9pwS8vMkEwVUdrnKCoIlVwJPm3+UVGs= github.com/gethinode/mod-utils/v5 v5.10.0/go.mod h1:PwQN4oOjA6k/vet11JueJ9asZMgL0DBa3jyS9tPkBWU= github.com/gethinode/mod-utils/v5 v5.11.0 h1:1BO9uK0zecHF6dNJcqX8NFNHSIdizlyj88n9ylLUsDc= @@ -84,3 +86,5 @@ github.com/gethinode/mod-utils/v5 v5.19.0 h1:fX3gTsYoimUNqD/KeBsyBrrJ2DygQ0M7Rc8 github.com/gethinode/mod-utils/v5 v5.19.0/go.mod h1:PwQN4oOjA6k/vet11JueJ9asZMgL0DBa3jyS9tPkBWU= github.com/gethinode/mod-utils/v5 v5.19.1 h1:peyYRxjIf8d84mt435veKaiO5nrIBXQ5xrHKHqcJehw= github.com/gethinode/mod-utils/v5 v5.19.1/go.mod h1:PwQN4oOjA6k/vet11JueJ9asZMgL0DBa3jyS9tPkBWU= +github.com/gethinode/mod-utils/v5 v5.20.0 h1:K+oBv8kJ4pVj4m1HlxgJiC+DYNX4oumqS6Cvcp2C8Ho= +github.com/gethinode/mod-utils/v5 v5.20.0/go.mod h1:PwQN4oOjA6k/vet11JueJ9asZMgL0DBa3jyS9tPkBWU= diff --git a/go.mod b/go.mod index 801f332..85ba368 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,5 @@ go 1.19 require ( github.com/cloudcannon/bookshop/hugo/v3 v3.18.2 // indirect - github.com/gethinode/mod-utils/v5 v5.19.1 // indirect + github.com/gethinode/mod-utils/v5 v5.20.0 // indirect ) diff --git a/go.sum b/go.sum index efea224..49bba4c 100644 --- a/go.sum +++ b/go.sum @@ -32,3 +32,5 @@ github.com/gethinode/mod-utils/v5 v5.19.0 h1:fX3gTsYoimUNqD/KeBsyBrrJ2DygQ0M7Rc8 github.com/gethinode/mod-utils/v5 v5.19.0/go.mod h1:PwQN4oOjA6k/vet11JueJ9asZMgL0DBa3jyS9tPkBWU= github.com/gethinode/mod-utils/v5 v5.19.1 h1:peyYRxjIf8d84mt435veKaiO5nrIBXQ5xrHKHqcJehw= github.com/gethinode/mod-utils/v5 v5.19.1/go.mod h1:PwQN4oOjA6k/vet11JueJ9asZMgL0DBa3jyS9tPkBWU= +github.com/gethinode/mod-utils/v5 v5.20.0 h1:K+oBv8kJ4pVj4m1HlxgJiC+DYNX4oumqS6Cvcp2C8Ho= +github.com/gethinode/mod-utils/v5 v5.20.0/go.mod h1:PwQN4oOjA6k/vet11JueJ9asZMgL0DBa3jyS9tPkBWU=