File tree Expand file tree Collapse file tree 7 files changed +99
-36
lines changed
exampleSite/content/test-product Expand file tree Collapse file tree 7 files changed +99
-36
lines changed Original file line number Diff line number Diff line change @@ -674,7 +674,6 @@ nav {
674
674
675
675
h2 {
676
676
font-size : 1.5rem ;
677
- margin : 1rem 0 0rem 0 ;
678
677
}
679
678
680
679
hr {
@@ -1188,6 +1187,35 @@ h6:has(a):hover {
1188
1187
color : oklch (var (--color-brand ));
1189
1188
}
1190
1189
1190
+ /* Landing page cards */
1191
+
1192
+ .text-content .card-layout {
1193
+ grid-column : 1 / -1 ;
1194
+
1195
+ .card-section {
1196
+ margin-bottom : 1rem ;
1197
+
1198
+ strong {
1199
+ font-weight : 500 ;
1200
+ }
1201
+ }
1202
+ }
1203
+
1204
+ /* Optional grid layout */
1205
+ .card-grid {
1206
+ display : grid;
1207
+ grid-template-columns : repeat (auto-fit, minmax (120px , 500px ));
1208
+ gap : 1.5rem ;
1209
+ margin-top : 1rem ;
1210
+
1211
+ .card {
1212
+ border : 1px solid oklch (var (--color-codeblock-border ));
1213
+ box-shadow : 3px 3px 0px oklch (var (--color-shadow ));
1214
+ padding : 1rem 2rem 2rem 2rem ;
1215
+ margin-bottom : 1.5rem ;
1216
+ }
1217
+ }
1218
+
1191
1219
/* MARK: Tables
1192
1220
*/
1193
1221
table {
Original file line number Diff line number Diff line change 2
2
description : Test pages for nginx-hugo-theme
3
3
title : Test pages
4
4
weight : 100
5
+ hasCustomContent : true
5
6
---
7
+ {{< card-layout >}}
8
+ {{< card-section >}}
9
+ {{< card title="Call Out usages" >}}
10
+ Examples for <call-out > shortcode
11
+ {{</ card >}}
12
+ {{< card title="Code Block usages" >}}
13
+ Examples for codeblock shortcode
14
+ {{</ card >}}
15
+ {{</ card-section >}}
16
+ {{</ card-layout >}}
Original file line number Diff line number Diff line change @@ -32,16 +32,17 @@ <h1>{{ .Title }}</h1>
32
32
33
33
{{ partial "banner" . }}
34
34
35
- {{ if (lt .WordCount 1) }}
36
- {{ .Content }}
37
- {{ range .Pages.ByWeight }}
38
- < h2 >
39
- < a href ="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}} "> {{ .Title }}</ a >
40
- </ h2 >
41
- {{ end }}
35
+ {{ $hasCustomContent := .Params.hasCustomContent | default false }}
36
+ {{ if $hasCustomContent }}
37
+ {{ partial "custom-landing-page" . }}
42
38
{{ else }}
43
- {{ partial "custom-landing-page" . }}
44
- {{end}}
39
+ {{ .Content }}
40
+ {{ range .Pages.ByWeight }}
41
+ < h2 >
42
+ < a href ="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}} "> {{ .Title }}</ a >
43
+ </ h2 >
44
+ {{ end }}
45
+ {{ end }}
45
46
46
47
< hr >
47
48
{{ if .Page.Lastmod }}
Original file line number Diff line number Diff line change 1
1
{{ $cards := .Scratch.Get "cards" }}
2
- {{ range .Pages.ByWeight }}
3
- {{ $title := .Title }}
4
- < h2 >
5
- < a href ="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}} "> {{ $title }}</ a >
6
- </ h2 >
7
- {{ range $cards }}
8
- {{ if eq .title $title }}
9
- < p style ="margin-left: 1rem; "> {{ .content }}</ p >
10
- {{ end }}
2
+ {{ $class := "card-grid wide"}}
3
+ < div >
4
+ {{ range .Pages.ByWeight }}
5
+ {{ $title := .Title }}
6
+ < div class ="card ">
7
+ < h2 >
8
+ < a href ="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}} "> {{ $title }}</ a >
9
+ </ h2 >
10
+ {{ range $cards }}
11
+ {{ if eq .title $title }}
12
+ < p > {{ .content }}</ p >
13
+ {{ end }}
14
+ {{ end }}
15
+ </ div >
11
16
{{ end }}
12
- {{ end }}
17
+ </ div >
13
18
{{ .Content }}
Original file line number Diff line number Diff line change 1
- < div data-mf ="true " style ="display: none "> {{- .Inner | markdownify -}}</ div >
1
+ < div class =" card-layout " data-mf ="true " style ="display: none "> {{- .Inner | markdownify -}}</ div >
Original file line number Diff line number Diff line change 1
- < div class ="card-section ">
2
- {{- if .Get "title" -}}
3
- < strong > {{- .Get "title" -}}</ strong >
4
- < div style ="padding-left: 1rem; "> {{- .Inner -}}</ div >
5
- {{ end }}
6
- </ div >
7
- < br > < br >
1
+ {{- /* Handle different versions of booleans */ -}}
2
+ {{ $showAsCards := .Get 0 | default (.Get "showAsCards") | default "false"}}
3
+ {{- /* 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 }}
7
+ {{ $class := "card-grid wide"}}
8
+ {{- /* Validate that the parent is card-layout */ -}}
9
+ {{ if eq .Parent.Name "card-layout"}}
10
+ < div class ="card-section ">
11
+ {{- if .Get "title" -}}
12
+ < strong class ="card-section-title "> {{- .Get "title" -}}</ strong >
13
+ < div class ="card-section-content{{ if eq $showAsCards "true " }} {{ $class }} {{ end }}"> {{- .Inner -}}</ div >
14
+ {{ end }}
15
+ </ div >
16
+ {{ else }}
17
+ {{ errorf "The '< card-section > ' must be nested directly inside the shortcode '< card-layout > '. Please see the exampleSite for an example of usage." }}
18
+ {{ end }}
Original file line number Diff line number Diff line change 2
2
{{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}}
3
3
{{- .Page.Scratch.Set "cards" ($current | append $newCard) -}}
4
4
5
- {{- if .Get "title" -}}
6
- {{- if .Get "titleUrl" -}}
7
- < h2 style ="padding: 0; "> < a href ="{{- .Get "titleUrl " -}}"> {{- .Get "title" -}}</ a > </ h2 >
8
- {{- else -}}
9
- < h2 style ="padding: 0; "> {{- .Get "title" -}}</ h2 >
10
- {{- end -}}
11
- {{ end }}
12
- < p > {{- .Inner -}}</ p >
5
+ {{- /* Validate that the parent is card-section */ -}}
6
+ {{ if eq .Parent.Name "card-section"}}
7
+ < div class ="card ">
8
+ {{- if .Get "title" -}}
9
+ {{- if .Get "titleUrl" -}}
10
+ < h2 class ="card-title "> < a href ="{{- .Get "titleUrl " -}}"> {{- .Get "title" -}}</ a > </ h2 >
11
+ {{- else -}}
12
+ < h2 class ="card-title "> {{- .Get "title" -}}</ h2 >
13
+ {{- end -}}
14
+ {{ end }}
15
+ < p > {{- .Inner -}}</ p >
16
+ </ div >
17
+ {{ else }}
18
+ {{ errorf "The '< card > ' must be nested directly inside the shortcode '< card-section > '. Please see the exampleSite for an example of usage." }}
19
+ {{ end }}
You can’t perform that action at this time.
0 commit comments