Skip to content

Commit cd58102

Browse files
committed
Landing: Fixed issue with showAsCards applying universally
1 parent a568e47 commit cd58102

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

exampleSite/content/test-product/_index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ weight: 100
55
hasCustomContent: true
66
---
77
{{< card-layout >}}
8+
<!-- If there is no "title" for <card-section>, it is implied it is the main content section and not a new content section -->
89
{{< card-section >}}
910
{{< card title="Call Out usages" >}}
1011
Examples for <call-out> shortcode
@@ -13,4 +14,11 @@ hasCustomContent: true
1314
Examples for codeblock shortcode
1415
{{</ card >}}
1516
{{</ card-section >}}
17+
18+
# Other Products on ExampleSite
19+
{{< card-section title="NGINX" showAsCards="true" >}}
20+
{{< card title="NGINX Plus" titleUrl="/nginx/" >}}
21+
Installing NGINX
22+
{{</ card >}}
23+
{{</ card-section >}}
1624
{{</ card-layout >}}

layouts/partials/custom-landing-page.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{{ $cards := .Scratch.Get "cards" }}
2+
{{ $showAsCards := index (.Scratch.Get "showAsCards") "main" }}
3+
{{ .Scratch.Get "showAsCards" }}
24
{{ $class := "card-grid wide"}}
3-
<div>
5+
6+
<div class="{{ if eq $showAsCards "true" }} {{ $class }} {{ end }}">
47
{{ range .Pages.ByWeight }}
58
{{ $title := .Title }}
69
<div class="card">

layouts/shortcodes/card-section.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
{{ if not (in (slice "true" "false") $showAsCards) }}
55
{{ warnf "The '<card-section>' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCards}}
66
{{ end }}
7+
{{- $current := .Page.Scratch.Get "showAsCards" | default (dict) -}}
8+
{{- $newShowAsCards := dict (.Get "title" | default "main") ($showAsCards) -}}
9+
{{- .Page.Scratch.Set "showAsCards" (merge $current ($newShowAsCards)) -}}
710
{{ $class := "card-grid wide"}}
811
{{- /* Validate that the parent is card-layout */ -}}
912
{{ if eq .Parent.Name "card-layout"}}

layouts/shortcodes/card.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{{- $current := .Page.Scratch.Get "cards" | default (slice) -}}
22
{{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}}
33
{{- .Page.Scratch.Set "cards" ($current | append $newCard) -}}
4-
54
{{- /* Validate that the parent is card-section */ -}}
65
{{ if eq .Parent.Name "card-section"}}
76
<div class="card">

0 commit comments

Comments
 (0)