Skip to content

Commit 7a55659

Browse files
committed
Landing: Added extra doc to exampleSite
1 parent 40bf3e5 commit 7a55659

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

exampleSite/content/test-product/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ title: Test pages
44
weight: 100
55
hasCustomContent: true
66
---
7+
<!-- <card-layout> - Available params: title (required: string)-->
78
{{< card-layout >}}
9+
<!-- <card-section> - Available params: title (required: string), showAsCards (optional: boolean, default false) -->
810
<!-- If there is no "title" for <card-section>, it is implied it is the main content section and not a new content section -->
911
{{< card-section >}}
1012
{{< card title="Call Out usages" >}}
13+
<!-- <card> - Available params: title (required: string), titleUrl (optional: string, relative path or absolute URL (e.g. https://google.com)) -->
1114
Examples for call-out shortcode
1215
{{</ card >}}
1316
{{< card title="Code Block usages" >}}

layouts/shortcodes/card-section.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
{{- /* Handle different versions of booleans */ -}}
2-
{{ $showAsCards := .Get 0 | default (.Get "showAsCards") | default "false"}}
1+
{{ $title := .Get "title" }}
2+
{{ $showAsCardsParam := .Get "showAsCards" | default "false"}}
33
{{- /* Validate the parameter strictly */ -}}
4-
{{ if not (in (slice "true" "false") $showAsCards) }}
5-
{{ warnf "The '<card-section>' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCards}}
6-
{{ end }}
4+
{{- if not (in (slice "true" "false") $showAsCardsParam) -}}
5+
{{- warnf "The '<card-section>' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCardsParam -}}
6+
{{- end -}}
7+
{{- $showAsCards := cond (eq $showAsCardsParam "true") "true" "false" -}}
78
{{- $current := .Page.Scratch.Get "showAsCards" | default (dict) -}}
8-
{{- $newShowAsCards := dict (.Get "title" | default "main") ($showAsCards) -}}
9+
{{- $newShowAsCards := dict ($title | default "main") ($showAsCards) -}}
910
{{- .Page.Scratch.Set "showAsCards" (merge $current ($newShowAsCards)) -}}
10-
{{ $class := "card-grid wide"}}
11+
{{- $class := "card-grid wide" -}}
1112
{{- /* Validate that the parent is card-layout */ -}}
1213
{{ if eq .Parent.Name "card-layout"}}
1314
<div class="card-section" data-mf="true" style="display: none;">
14-
{{- if .Get "title" -}}
15-
<strong class="card-section-title">{{- .Get "title" -}}</strong>
15+
{{- if $title -}}
16+
<strong class="card-section-title">{{- $title -}}</strong>
1617
<div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }} {{ end }}">{{- .Inner -}}</div>
1718
{{ end }}
1819
</div>
1920
<div class="row" data-mf="false">
20-
{{- if .Get "title" -}}
21-
<strong class="card-section-title">{{- .Get "title" -}}</strong>
21+
{{- if $title -}}
22+
<strong class="card-section-title">{{- $title -}}</strong>
2223
<div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }} {{ end }} card-deck">{{- .Inner -}}</div>
2324
{{ end }}
2425
</div>

layouts/shortcodes/card.html

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
1+
{{- $title := .Get "title" -}}
2+
{{- $titleUrl := .Get "titleUrl" | default "/" -}}
3+
{{- $icon := .Get "icon" | default "NGINX-product-icon" -}}
14
{{- $current := .Page.Scratch.Get "cards" | default (slice) -}}
2-
{{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}}
5+
{{- $newCard := dict "title" ($title) "content" (.Inner) -}}
36
{{- .Page.Scratch.Set "cards" ($current | append $newCard) -}}
47
{{- /* Validate that the parent is card-section */ -}}
5-
{{ if eq .Parent.Name "card-section"}}
8+
{{- if eq .Parent.Name "card-section" -}}
69
<div class="card-container" style="display: none;" data-mf="true">
7-
{{- if .Get "title" -}}
8-
{{- if .Get "titleUrl" -}}
9-
<h2 class="card-title"><a href="{{- .Get "titleUrl" -}}">{{- .Get "title" -}}</a></h2>
10+
{{- if $title -}}
11+
{{- if $titleUrl -}}
12+
<h2 class="card-title"><a href="{{- $titleUrl -}}">{{- $title -}}</a></h2>
1013
{{- else -}}
11-
<h2 class="card-title">{{- .Get "title" -}}</h2>
14+
<h2 class="card-title">{{- $title -}}</h2>
1215
{{- end -}}
13-
{{ end }}
16+
{{- else -}}
17+
{{ errorf "Mainframe: Missing param 'title'" }}
18+
{{- end -}}
1419
<p>{{- .Inner -}}</p>
1520
</div>
1621
<div class="col-md-5 card" data-mf="false">
1722
<div class="card-body">
1823
<h3 class="card-title" style="display: flex; align-items: center; gap: 5px;">
19-
{{- if .Get "icon" -}}
20-
<img class="card-img-top" src="{{ .Site.BaseURL }}/images/icons/{{ .Get "icon" }}.png"/>
24+
{{- if $icon -}}
25+
<img class="card-img-top" src="{{ .Site.BaseURL }}/images/icons/{{ $icon }}.png"/>
26+
{{- end -}}
27+
{{- if ($title) -}}
28+
<a href="{{- $titleUrl -}}">{{- $title -}}</a>
29+
{{- else -}}
30+
{{ errorf "Old theme: Missing param 'title'" }}
2131
{{- end -}}
22-
<a href="{{- .Get "titleUrl" -}}">{{- .Get "title" -}}</a>
2332
</h3>
2433
<p>{{- .Inner -}}</p>
2534
</div>
2635
</div>
27-
{{ else }}
36+
{{- else -}}
2837
{{ errorf "The '<card>' must be nested directly inside the shortcode '<card-section>'. Please see the exampleSite for an example of usage." }}
29-
{{ end }}
38+
{{- end -}}

0 commit comments

Comments
 (0)