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. 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 }} -