From 1df645c7226dcfe60b5923df4fee43939fe34ad7 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 30 May 2025 12:05:09 -0700 Subject: [PATCH 1/6] Landing: Added new shortcodes + partials to support custom landing page --- layouts/_default/list.html | 4 +++- layouts/partials/custom-landing-page.html | 13 +++++++++++++ layouts/shortcodes/card-layout.html | 1 + layouts/shortcodes/card-section.html | 7 +++++++ layouts/shortcodes/card.html | 12 ++++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/custom-landing-page.html create mode 100644 layouts/shortcodes/card-layout.html create mode 100644 layouts/shortcodes/card-section.html create mode 100644 layouts/shortcodes/card.html diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 6164c75..4e2b2a8 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -29,16 +29,18 @@ {{ end }}

{{ .Title }}

- {{ .Content }} {{ partial "banner" . }} {{ if (lt .WordCount 1) }} + {{ .Content }} {{ range .Pages.ByWeight }}

{{ .Title }}

{{ end }} + {{ else }} + {{ partial "custom-landing-page" . }} {{end}}
diff --git a/layouts/partials/custom-landing-page.html b/layouts/partials/custom-landing-page.html new file mode 100644 index 0000000..d0962a8 --- /dev/null +++ b/layouts/partials/custom-landing-page.html @@ -0,0 +1,13 @@ +{{ $cards := .Scratch.Get "cards" }} +{{ range .Pages.ByWeight }} +{{ $title := .Title }} +

+ {{ $title }} +

+ {{ range $cards }} + {{ if eq .title $title }} +

{{ .content }}

+ {{ end }} + {{ end }} +{{ end }} +{{ .Content }} \ No newline at end of file diff --git a/layouts/shortcodes/card-layout.html b/layouts/shortcodes/card-layout.html new file mode 100644 index 0000000..f81ffa9 --- /dev/null +++ b/layouts/shortcodes/card-layout.html @@ -0,0 +1 @@ +{{- .Inner | markdownify -}} \ No newline at end of file diff --git a/layouts/shortcodes/card-section.html b/layouts/shortcodes/card-section.html new file mode 100644 index 0000000..70988e7 --- /dev/null +++ b/layouts/shortcodes/card-section.html @@ -0,0 +1,7 @@ +
+ {{- if .Get "title" -}} + {{- .Get "title" -}} +
{{- .Inner -}}
+ {{ end }} +
+

\ No newline at end of file diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html new file mode 100644 index 0000000..fa30d47 --- /dev/null +++ b/layouts/shortcodes/card.html @@ -0,0 +1,12 @@ +{{- $current := .Page.Scratch.Get "cards" | default (slice) -}} +{{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}} +{{- .Page.Scratch.Set "cards" ($current | append $newCard) -}} + +{{- if .Get "title" -}} + {{- if .Get "titleUrl" -}} +

{{- .Get "title" -}}

+ {{- else -}} +

{{- .Get "title" -}}

+ {{- end -}} +{{ end }} +

{{- .Inner -}}

\ No newline at end of file From 57c40a70d788178c3df8b6296349f0d7ff7589fd Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 30 May 2025 12:16:36 -0700 Subject: [PATCH 2/6] Landing: Added data-mf to card layout --- layouts/shortcodes/card-layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/shortcodes/card-layout.html b/layouts/shortcodes/card-layout.html index f81ffa9..fd53f44 100644 --- a/layouts/shortcodes/card-layout.html +++ b/layouts/shortcodes/card-layout.html @@ -1 +1 @@ -{{- .Inner | markdownify -}} \ No newline at end of file +
{{- .Inner | markdownify -}}
\ No newline at end of file From a568e47e90e450ea3e5501f0367eae9a1900b89c Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Tue, 3 Jun 2025 11:19:28 -0700 Subject: [PATCH 3/6] Landing: Polished code + added error handling --- assets/css/v2/style.css | 30 +++++++++++++++++++++- exampleSite/content/test-product/_index.md | 11 ++++++++ layouts/_default/list.html | 19 +++++++------- layouts/partials/custom-landing-page.html | 25 ++++++++++-------- layouts/shortcodes/card-layout.html | 2 +- layouts/shortcodes/card-section.html | 25 +++++++++++++----- layouts/shortcodes/card.html | 23 +++++++++++------ 7 files changed, 99 insertions(+), 36 deletions(-) diff --git a/assets/css/v2/style.css b/assets/css/v2/style.css index 64bfe7e..4b57100 100644 --- a/assets/css/v2/style.css +++ b/assets/css/v2/style.css @@ -674,7 +674,6 @@ nav { h2 { font-size: 1.5rem; - margin: 1rem 0 0rem 0; } hr { @@ -1188,6 +1187,35 @@ h6:has(a):hover { color: oklch(var(--color-brand)); } +/* Landing page cards */ + +.text-content .card-layout { + grid-column: 1 / -1; + + .card-section { + margin-bottom: 1rem; + + strong { + font-weight: 500; + } + } +} + +/* Optional grid layout */ +.card-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(120px, 500px)); + gap: 1.5rem; + margin-top: 1rem; + + .card { + border: 1px solid oklch(var(--color-codeblock-border)); + box-shadow: 3px 3px 0px oklch(var(--color-shadow)); + padding: 1rem 2rem 2rem 2rem; + margin-bottom: 1.5rem; + } +} + /* MARK: Tables */ table { diff --git a/exampleSite/content/test-product/_index.md b/exampleSite/content/test-product/_index.md index 5b74134..c1555ee 100644 --- a/exampleSite/content/test-product/_index.md +++ b/exampleSite/content/test-product/_index.md @@ -2,4 +2,15 @@ description: Test pages for nginx-hugo-theme title: Test pages weight: 100 +hasCustomContent: true --- +{{< card-layout >}} + {{< card-section >}} + {{< card title="Call Out usages" >}} + Examples for shortcode + {{}} + {{< card title="Code Block usages" >}} + Examples for codeblock shortcode + {{}} + {{}} +{{}} \ No newline at end of file diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 4e2b2a8..27ef6dc 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -32,16 +32,17 @@

{{ .Title }}

{{ partial "banner" . }} - {{ if (lt .WordCount 1) }} - {{ .Content }} - {{ range .Pages.ByWeight }} -

- {{ .Title }} -

- {{ end }} + {{ $hasCustomContent := .Params.hasCustomContent | default false }} + {{ if $hasCustomContent }} + {{ partial "custom-landing-page" . }} {{ else }} - {{ partial "custom-landing-page" . }} - {{end}} + {{ .Content }} + {{ range .Pages.ByWeight }} +

+ {{ .Title }} +

+ {{ end }} + {{ end }}
{{ if .Page.Lastmod }} diff --git a/layouts/partials/custom-landing-page.html b/layouts/partials/custom-landing-page.html index d0962a8..c01d4fd 100644 --- a/layouts/partials/custom-landing-page.html +++ b/layouts/partials/custom-landing-page.html @@ -1,13 +1,18 @@ {{ $cards := .Scratch.Get "cards" }} -{{ range .Pages.ByWeight }} -{{ $title := .Title }} -

- {{ $title }} -

- {{ range $cards }} - {{ if eq .title $title }} -

{{ .content }}

- {{ end }} +{{ $class := "card-grid wide"}} +
+ {{ range .Pages.ByWeight }} + {{ $title := .Title }} +
+

+ {{ $title }} +

+ {{ range $cards }} + {{ if eq .title $title }} +

{{ .content }}

+ {{ end }} + {{ end }} +
{{ end }} -{{ end }} +
{{ .Content }} \ No newline at end of file diff --git a/layouts/shortcodes/card-layout.html b/layouts/shortcodes/card-layout.html index fd53f44..1fdd57a 100644 --- a/layouts/shortcodes/card-layout.html +++ b/layouts/shortcodes/card-layout.html @@ -1 +1 @@ -
{{- .Inner | markdownify -}}
\ No newline at end of file + \ No newline at end of file diff --git a/layouts/shortcodes/card-section.html b/layouts/shortcodes/card-section.html index 70988e7..85c28f5 100644 --- a/layouts/shortcodes/card-section.html +++ b/layouts/shortcodes/card-section.html @@ -1,7 +1,18 @@ -
- {{- if .Get "title" -}} - {{- .Get "title" -}} -
{{- .Inner -}}
- {{ end }} -
-

\ No newline at end of file +{{- /* Handle different versions of booleans */ -}} +{{ $showAsCards := .Get 0 | default (.Get "showAsCards") | default "false"}} +{{- /* Validate the parameter strictly */ -}} +{{ if not (in (slice "true" "false") $showAsCards) }} + {{ warnf "The '' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCards}} +{{ end }} +{{ $class := "card-grid wide"}} +{{- /* Validate that the parent is card-layout */ -}} +{{ if eq .Parent.Name "card-layout"}} +
+ {{- if .Get "title" -}} + {{- .Get "title" -}} +
{{- .Inner -}}
+ {{ end }} +
+{{ else }} + {{ errorf "The '' must be nested directly inside the shortcode ''. Please see the exampleSite for an example of usage." }} +{{ end }} \ No newline at end of file diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index fa30d47..71850bd 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -2,11 +2,18 @@ {{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}} {{- .Page.Scratch.Set "cards" ($current | append $newCard) -}} -{{- if .Get "title" -}} - {{- if .Get "titleUrl" -}} -

{{- .Get "title" -}}

- {{- else -}} -

{{- .Get "title" -}}

- {{- end -}} -{{ end }} -

{{- .Inner -}}

\ No newline at end of file +{{- /* Validate that the parent is card-section */ -}} +{{ if eq .Parent.Name "card-section"}} +
+ {{- if .Get "title" -}} + {{- if .Get "titleUrl" -}} +

{{- .Get "title" -}}

+ {{- else -}} +

{{- .Get "title" -}}

+ {{- end -}} + {{ end }} +

{{- .Inner -}}

+
+{{ else }} + {{ errorf "The '' must be nested directly inside the shortcode ''. Please see the exampleSite for an example of usage." }} +{{ end }} \ No newline at end of file From 1b87b45589b8a59901553349b4d661cad669109a Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Tue, 3 Jun 2025 12:55:43 -0700 Subject: [PATCH 4/6] Landing: Fixed issue with showAsCards applying universally --- exampleSite/content/test-product/_index.md | 8 ++++++++ layouts/partials/custom-landing-page.html | 4 +++- layouts/shortcodes/card-section.html | 3 +++ layouts/shortcodes/card.html | 1 - 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/exampleSite/content/test-product/_index.md b/exampleSite/content/test-product/_index.md index c1555ee..c8ea37f 100644 --- a/exampleSite/content/test-product/_index.md +++ b/exampleSite/content/test-product/_index.md @@ -5,6 +5,7 @@ weight: 100 hasCustomContent: true --- {{< card-layout >}} + {{< card-section >}} {{< card title="Call Out usages" >}} Examples for shortcode @@ -13,4 +14,11 @@ hasCustomContent: true Examples for codeblock shortcode {{}} {{}} + + # Other Products on ExampleSite + {{< card-section title="NGINX" showAsCards="true" >}} + {{< card title="NGINX Plus" titleUrl="/nginx/" >}} + Installing NGINX + {{}} + {{}} {{}} \ No newline at end of file diff --git a/layouts/partials/custom-landing-page.html b/layouts/partials/custom-landing-page.html index c01d4fd..c2c50de 100644 --- a/layouts/partials/custom-landing-page.html +++ b/layouts/partials/custom-landing-page.html @@ -1,6 +1,8 @@ {{ $cards := .Scratch.Get "cards" }} +{{ $showAsCards := index (.Scratch.Get "showAsCards") "main" }} {{ $class := "card-grid wide"}} -
+ +
{{ range .Pages.ByWeight }} {{ $title := .Title }}
diff --git a/layouts/shortcodes/card-section.html b/layouts/shortcodes/card-section.html index 85c28f5..80c351d 100644 --- a/layouts/shortcodes/card-section.html +++ b/layouts/shortcodes/card-section.html @@ -4,6 +4,9 @@ {{ if not (in (slice "true" "false") $showAsCards) }} {{ warnf "The '' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCards}} {{ end }} +{{- $current := .Page.Scratch.Get "showAsCards" | default (dict) -}} +{{- $newShowAsCards := dict (.Get "title" | default "main") ($showAsCards) -}} +{{- .Page.Scratch.Set "showAsCards" (merge $current ($newShowAsCards)) -}} {{ $class := "card-grid wide"}} {{- /* Validate that the parent is card-layout */ -}} {{ if eq .Parent.Name "card-layout"}} diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index 71850bd..d68f1d1 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -1,7 +1,6 @@ {{- $current := .Page.Scratch.Get "cards" | default (slice) -}} {{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}} {{- .Page.Scratch.Set "cards" ($current | append $newCard) -}} - {{- /* Validate that the parent is card-section */ -}} {{ if eq .Parent.Name "card-section"}}
From 40bf3e5325a2b1bd59187fa59bfcc2db8ab0bcfb Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 4 Jun 2025 12:43:26 -0700 Subject: [PATCH 5/6] Landing: Fixed bug with old theme not rendering all custom content --- assets/css/f5-hugo.css | 10 ++ assets/css/v2/style.css | 2 +- exampleSite/content/test-product/_index.md | 2 +- layouts/_default/list.html | 4 +- layouts/partials/custom-landing-page.html | 62 ++++++++---- layouts/partials/list-main.html | 106 +++++---------------- layouts/shortcodes/card-layout.html | 6 +- layouts/shortcodes/card-section.html | 8 +- layouts/shortcodes/card.html | 13 ++- layouts/shortcodes/changelog-dates.html | 1 + 10 files changed, 109 insertions(+), 105 deletions(-) create mode 100644 layouts/shortcodes/changelog-dates.html diff --git a/assets/css/f5-hugo.css b/assets/css/f5-hugo.css index 3f82f1e..03b6b5c 100644 --- a/assets/css/f5-hugo.css +++ b/assets/css/f5-hugo.css @@ -423,6 +423,16 @@ h3.card-title { font-weight: 400; } +/* Landing page cards */ +.text-content .card-layout { + .card-section { + margin-bottom: 1rem; + + strong { + font-weight: 500; + } + } +} #f5-related, #nginx-products { width: 100%; diff --git a/assets/css/v2/style.css b/assets/css/v2/style.css index 4b57100..f920dc6 100644 --- a/assets/css/v2/style.css +++ b/assets/css/v2/style.css @@ -1208,7 +1208,7 @@ h6:has(a):hover { gap: 1.5rem; margin-top: 1rem; - .card { + .card-container { border: 1px solid oklch(var(--color-codeblock-border)); box-shadow: 3px 3px 0px oklch(var(--color-shadow)); padding: 1rem 2rem 2rem 2rem; diff --git a/exampleSite/content/test-product/_index.md b/exampleSite/content/test-product/_index.md index c8ea37f..d25eda2 100644 --- a/exampleSite/content/test-product/_index.md +++ b/exampleSite/content/test-product/_index.md @@ -8,7 +8,7 @@ hasCustomContent: true {{< card-section >}} {{< card title="Call Out usages" >}} - Examples for shortcode + Examples for call-out shortcode {{}} {{< card title="Code Block usages" >}} Examples for codeblock shortcode diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 27ef6dc..ca57cec 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -34,7 +34,9 @@

{{ .Title }}

{{ $hasCustomContent := .Params.hasCustomContent | default false }} {{ if $hasCustomContent }} - {{ partial "custom-landing-page" . }} + {{ .Page.Scratch.Set "custom-landing-page-file-name" "custom-landing-page.html" }} + {{ .Page.Scratch.Set "custom-landing-page-context" . }} + {{ .Content }} {{ else }} {{ .Content }} {{ range .Pages.ByWeight }} diff --git a/layouts/partials/custom-landing-page.html b/layouts/partials/custom-landing-page.html index c2c50de..fb9d553 100644 --- a/layouts/partials/custom-landing-page.html +++ b/layouts/partials/custom-landing-page.html @@ -1,20 +1,48 @@ -{{ $cards := .Scratch.Get "cards" }} -{{ $showAsCards := index (.Scratch.Get "showAsCards") "main" }} +{{ $cards := .Page.Scratch.Get "cards" }} +{{ $showAsCards := index ( .Page.Scratch.Get "showAsCards") "main" }} {{ $class := "card-grid wide"}} -
- {{ range .Pages.ByWeight }} - {{ $title := .Title }} -
-

- {{ $title }} -

- {{ range $cards }} - {{ if eq .title $title }} -

{{ .content }}

+
+ +
+
+
+ {{ range .Pages.GroupBy "Section" }} + {{ range .Pages.ByWeight }} + {{ $title := .Title }} +
+
+

+ + {{ .Title }} +

+ {{ range $cards }} + {{ if eq .title $title }} +

{{ .content }}

+ {{ end }} + {{ end }} +
+
+ {{ end }} {{ end }} - {{ end }} -
- {{ end }} -
-{{ .Content }} \ No newline at end of file +
+
+ + + +
+ {{ range .Pages.ByWeight }} + {{ $title := .Title }} +
+

+ {{ $title }} +

+ {{ range $cards }} + {{ if eq .title $title }} +

{{- .content -}}

+ {{ end }} + {{ end }} +
+ {{ end }} +
+
\ No newline at end of file diff --git a/layouts/partials/list-main.html b/layouts/partials/list-main.html index 84777ad..26cc2ba 100644 --- a/layouts/partials/list-main.html +++ b/layouts/partials/list-main.html @@ -10,91 +10,33 @@

{{ .Description | markdownify }}

{{ end}} - {{ if .Content }} -

- {{ .Content | markdownify }} -

- {{ end }} - {{ partial "banner" .}} -

-
- - {{ if or (lt .WordCount 1) (eq $PageTitle "F5 NGINX One Console") (eq $PageTitle "F5 NGINX App Protect DoS") (eq $PageTitle "F5 NGINX Plus") }} -
-
-
- {{ range .Pages.GroupBy "Section" }} - {{ range .Pages.ByWeight }} -
-
+ {{ $hasCustomContent := .Params.hasCustomContent | default false }} + {{ if $hasCustomContent }} + {{ .Page.Scratch.Set "custom-landing-page-file-name" "custom-landing-page.html" }} + {{ .Page.Scratch.Set "custom-landing-page-context" . }} + {{ .Content }} + {{ else }} +
+
+
+ {{ range .Pages.GroupBy "Section" }} + {{ range .Pages.ByWeight }} + {{ $title := .Title }} +
+

- - {{ .Title }} + + {{ .Title }}

- {{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "How-to guides") }} -
    - {{ range .Pages }} - {{ if eq .Kind "section" }} - {{ range .Pages }} -
  • {{ .Title }}
  • - {{ end }} - {{ end }} - {{ end }} -
- {{ end }} - {{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "API")}} - - {{ end }} - {{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "Changelog") }} - {{ partial "changelog-date.html" . }} - {{ end }} +
-
+ {{ end }} {{ end }} - {{ end }} -
- {{ if eq $PageTitle "F5 NGINX One Console" }} -

Other Products

- {{ $nginxProducts := slice - (dict "title" "NGINX Instance Manager" "url" "/nginx-instance-manager" "imgSrc" "NGINX-Instance-Manager-product-icon" "type" "local-console-option" "description" "Track and control NGINX Open Source and NGINX Plus instances.") - (dict "title" "NGINX Ingress Controller" "url" "/nginx-ingress-controller" "imgSrc" "NGINX-Ingress-Controller-product-icon" "type" "kubernetes-solutions" "description" "Kubernetes traffic management with API gateway, identity, and observability features.") - (dict "title" "NGINX Gateway Fabric" "url" "/nginx-gateway-fabric" "imgSrc" "NGINX-product-icon" "type" "kubernetes-solutions" "description" "Next generation Kubernetes connectivity using the Gateway API.") - (dict "title" "NGINX App Protect WAF" "url" "/nginx-app-protect-waf" "imgSrc" "NGINX-App-Protect-WAF-product-icon" "type" "security" "description" "Lightweight, high-performance, advanced protection against Layer 7 attacks on your apps and APIs.") - (dict "title" "NGINX App Protect DoS" "url" "/nginx-app-protect-dos" "imgSrc" "NGINX-App-Protect-DoS-product-icon" "type" "security" "description" "Defend, adapt, and mitigate against Layer 7 denial-of-service attacks on your apps and APIs.") - (dict "title" "NGINX Plus" "url" "/nginx" "imgSrc" "NGINX-Plus-product-icon-RGB" "type" "modern-app-delivery" "description" "The all-in-one load balancer, reverse proxy, web server, content cache, and API gateway.") - (dict "title" "NGINX Open Source" "url" "https://nginx.org/en/docs/" "imgSrc" "NGINX-product-icon" "type" "modern-app-delivery" "description" "The open source all-in-one load balancer, content cache, and web server") - }} - {{ $groupedProducts := dict - "local-console-option" (where $nginxProducts "type" "local-console-option") - "kubernetes-solutions" (where $nginxProducts "type" "kubernetes-solutions") - "security" (where $nginxProducts "type" "security") - "modern-app-delivery" (where $nginxProducts "type" "modern-app-delivery") - }} - {{ range $type, $products := $groupedProducts }} -
-

{{ $type | humanize | title }}

- {{ range $products }} -
-
-

- - {{ .title }} -

-

- {{ if .description }}{{ .description | markdownify }}{{ end }} -

-
-
- {{ end }} -
- {{ end }} - {{ end }} -
-
- {{end}} +
+
+ + {{ end }} + + \ No newline at end of file diff --git a/layouts/shortcodes/card-layout.html b/layouts/shortcodes/card-layout.html index 1fdd57a..564b334 100644 --- a/layouts/shortcodes/card-layout.html +++ b/layouts/shortcodes/card-layout.html @@ -1 +1,5 @@ - \ No newline at end of file + +{{ $customLandingPageFileName := .Page.Scratch.Get "custom-landing-page-file-name" }} +{{ $customLandingPageContext := .Page.Scratch.Get "custom-landing-page-context" }} +{{ partial $customLandingPageFileName $customLandingPageContext }} +
{{- .Inner | markdownify -}}
\ No newline at end of file diff --git a/layouts/shortcodes/card-section.html b/layouts/shortcodes/card-section.html index 80c351d..894190f 100644 --- a/layouts/shortcodes/card-section.html +++ b/layouts/shortcodes/card-section.html @@ -10,12 +10,18 @@ {{ $class := "card-grid wide"}} {{- /* Validate that the parent is card-layout */ -}} {{ if eq .Parent.Name "card-layout"}} -
+ +
+ {{- if .Get "title" -}} + {{- .Get "title" -}} +
{{- .Inner -}}
+ {{ end }} +
{{ else }} {{ errorf "The '' must be nested directly inside the shortcode ''. Please see the exampleSite for an example of usage." }} {{ end }} \ No newline at end of file diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index d68f1d1..1dfc080 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -3,7 +3,7 @@ {{- .Page.Scratch.Set "cards" ($current | append $newCard) -}} {{- /* Validate that the parent is card-section */ -}} {{ if eq .Parent.Name "card-section"}} -
+ +
+
+

+ {{- if .Get "icon" -}} + + {{- end -}} + {{- .Get "title" -}} +

+

{{- .Inner -}}

+
+
{{ else }} {{ errorf "The '' must be nested directly inside the shortcode ''. Please see the exampleSite for an example of usage." }} {{ end }} \ No newline at end of file diff --git a/layouts/shortcodes/changelog-dates.html b/layouts/shortcodes/changelog-dates.html new file mode 100644 index 0000000..0e1f6ff --- /dev/null +++ b/layouts/shortcodes/changelog-dates.html @@ -0,0 +1 @@ +{{ partial "changelog-date.html" . }} \ No newline at end of file From 7a55659a0f43506c3933916329b02cc39560681e Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 4 Jun 2025 15:23:22 -0700 Subject: [PATCH 6/6] Landing: Added extra doc to exampleSite --- exampleSite/content/test-product/_index.md | 3 ++ layouts/shortcodes/card-section.html | 23 +++++++-------- layouts/shortcodes/card.html | 33 ++++++++++++++-------- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/exampleSite/content/test-product/_index.md b/exampleSite/content/test-product/_index.md index d25eda2..96b971a 100644 --- a/exampleSite/content/test-product/_index.md +++ b/exampleSite/content/test-product/_index.md @@ -4,10 +4,13 @@ title: Test pages weight: 100 hasCustomContent: true --- + {{< card-layout >}} + {{< card-section >}} {{< card title="Call Out usages" >}} + Examples for call-out shortcode {{}} {{< card title="Code Block usages" >}} diff --git a/layouts/shortcodes/card-section.html b/layouts/shortcodes/card-section.html index 894190f..11339a5 100644 --- a/layouts/shortcodes/card-section.html +++ b/layouts/shortcodes/card-section.html @@ -1,24 +1,25 @@ -{{- /* Handle different versions of booleans */ -}} -{{ $showAsCards := .Get 0 | default (.Get "showAsCards") | default "false"}} +{{ $title := .Get "title" }} +{{ $showAsCardsParam := .Get "showAsCards" | default "false"}} {{- /* Validate the parameter strictly */ -}} -{{ if not (in (slice "true" "false") $showAsCards) }} - {{ warnf "The '' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCards}} -{{ end }} +{{- if not (in (slice "true" "false") $showAsCardsParam) -}} + {{- warnf "The '' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCardsParam -}} +{{- end -}} +{{- $showAsCards := cond (eq $showAsCardsParam "true") "true" "false" -}} {{- $current := .Page.Scratch.Get "showAsCards" | default (dict) -}} -{{- $newShowAsCards := dict (.Get "title" | default "main") ($showAsCards) -}} +{{- $newShowAsCards := dict ($title | default "main") ($showAsCards) -}} {{- .Page.Scratch.Set "showAsCards" (merge $current ($newShowAsCards)) -}} -{{ $class := "card-grid wide"}} +{{- $class := "card-grid wide" -}} {{- /* Validate that the parent is card-layout */ -}} {{ if eq .Parent.Name "card-layout"}}
- {{- if .Get "title" -}} - {{- .Get "title" -}} + {{- if $title -}} + {{- $title -}}
{{- .Inner -}}
{{ end }}
diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index 1dfc080..f48bd6d 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -1,29 +1,38 @@ +{{- $title := .Get "title" -}} +{{- $titleUrl := .Get "titleUrl" | default "/" -}} +{{- $icon := .Get "icon" | default "NGINX-product-icon" -}} {{- $current := .Page.Scratch.Get "cards" | default (slice) -}} -{{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}} +{{- $newCard := dict "title" ($title) "content" (.Inner) -}} {{- .Page.Scratch.Set "cards" ($current | append $newCard) -}} {{- /* Validate that the parent is card-section */ -}} -{{ if eq .Parent.Name "card-section"}} +{{- if eq .Parent.Name "card-section" -}}

- {{- if .Get "icon" -}} - + {{- if $icon -}} + + {{- end -}} + {{- if ($title) -}} + {{- $title -}} + {{- else -}} + {{ errorf "Old theme: Missing param 'title'" }} {{- end -}} - {{- .Get "title" -}}

{{- .Inner -}}

-{{ else }} +{{- else -}} {{ errorf "The '' must be nested directly inside the shortcode ''. Please see the exampleSite for an example of usage." }} -{{ end }} \ No newline at end of file +{{- end -}} \ No newline at end of file