2
2
{{- $titleUrl := .Get "titleUrl" | default "/" -}}
3
3
{{- $icon := .Get "icon" | default "book-open" -}}
4
4
{{- $brandIcon := .Get "brandIcon" -}}
5
- {{- $isFeaturedParam := .Get "isFeatured" | default "false" }}
5
+ {{- $isFullSizeParam := .Get "isFullSize" | default "false" -}}
6
+ {{- $isLandingParam := .Get "isLanding" | default "false" }}
7
+
6
8
{{- /* Validate the parameter strictly */ -}}
7
- {{- if not (in (slice "true" "false") $isFeaturedParam ) -}}
8
- {{- warnf "The '< card > ' Shortcode parameter 'isFeatured ' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isFeaturedParam -}}
9
+ {{- if not (in (slice "true" "false") $isFullSizeParam ) -}}
10
+ {{- warnf "The '< card > ' Shortcode parameter 'isFullSize ' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isFullSizeParam -}}
9
11
{{- end -}}
10
- {{- $isFeatured := cond (eq $isFeaturedParam "true") "true" "false" -}}
11
- {{- $current := .Page.Scratch.Get "cards" | default (slice) -}}
12
- {{- $newCard := dict "title" ($title) "content" (.Inner) -}}
13
- {{- .Page.Scratch.Set "cards" ($current | append $newCard) -}}
12
+ {{- $isFullSize := cond (eq $isFullSizeParam "true") "true" "false" -}}
13
+
14
+ {{- if not (in (slice "true" "false") $isLandingParam) -}}
15
+ {{- warnf "The '< card > ' Shortcode parameter 'isLanding' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isLandingParam -}}
16
+ {{- end -}}
17
+ {{- $isLanding := cond (eq $isLandingParam "true") "true" "false" -}}
18
+
19
+ {{- /* Set up the positioning */ -}}
20
+ {{ $dataGrid := "" }}
21
+ {{ if eq $isFullSize "true" }}
22
+ {{ $dataGrid = "wide"}}
23
+ {{ else if (eq $isLanding "true") }}
24
+ {{ $dataGrid = "third"}}
25
+ {{ else }}
26
+ {{ $dataGrid = "half"}}
27
+ {{ end }}
28
+
29
+ {{- /* Build the url */ -}}
30
+ {{ $url := printf "%s%s" .Page.Permalink $titleUrl }}
31
+ {{ if eq (substr $titleUrl 0 1) "/" }}
32
+ {{ $url = printf "%s%s" .Site.BaseURL (substr $titleUrl 1) }}
33
+ {{ else if (strings.Contains $titleUrl "https") }}
34
+ {{ $url = $titleUrl }}
35
+ {{ end }}
36
+
14
37
{{- /* Validate that the parent is card-section and under 3 cards */ -}}
15
38
{{- if (eq .Parent.Name "card-section") -}}
16
- < div class ="card-container {{ if eq $isFeatured "true " }}featured-card{{ end }}" data-mf="true " style ="display: none; ">
39
+ < a href ="{{- $url -}} " alt ="{{- $title -}} " class ="card " data-grid ="{{ $dataGrid }} " data-testid ="card " data-mf ="true " style ="display: none; ">
40
+ < div class ="card-container ">
17
41
{{- if $title -}}
18
42
< div class ="card-header ">
19
43
{{- if $brandIcon -}}
20
- < img class ="card-brand-icon " src ="/images/icons/{{ $brandIcon }}.svg ">
21
- {{- else -}}
22
- {{- if $icon -}}
23
- {{ partial "lucide" (dict "context" . "icon" $icon) }}
24
- {{- end -}}
25
- {{- end -}}
26
- {{- if $titleUrl -}}
27
- < h2 class ="card-title "> < a href ="{{- $titleUrl -}} "> {{- $title -}}</ a > </ h2 >
28
- {{- else -}}
29
- < h2 class ="card-title "> {{- $title -}}</ h2 >
44
+ < img class ="card-brand-icon " src ="/images/icons/{{ $brandIcon }} ">
45
+ {{- else if $icon -}}
46
+ {{ partial "lucide" (dict "context" . "icon" $icon) }}
30
47
{{- end -}}
48
+ < h2 class ="card-title "> {{- $title -}}</ h2 >
31
49
</ div >
32
50
{{- else -}}
33
51
{{ errorf "Mainframe: Missing param 'title'" }}
34
52
{{- end -}}
35
- < p > {{- .Inner - }}</ p >
53
+ < div class =" card-content " > {{ .Inner }}</ div >
36
54
</ div >
37
- < div class =" col-md-5 card " data-mf =" false " >
38
- < div class ="card-body ">
39
- < h3 class ="card-title " style =" display: flex; align-items: center; gap: 5px; ">
40
- {{- if $brandIcon -}}
41
- < img class =" card-img-top " src =" {{ .Site.BaseURL }}/images/icons/{{ $brandIcon }}.png " />
42
- {{- else -}}
43
- < i class =" fas fa-file-alt fa-lg card-img-top " > </ i >
44
- {{- end -}}
45
- {{- if ($title) -}}
46
- < a href =" {{- $titleUrl -}} " > {{- $title -}}</ a >
47
- {{- else -}}
48
- {{ errorf "Old theme: Missing param 'title'" }}
49
- {{- end - }}
50
- </ h3 >
51
- < p > {{- .Inner -}} </ p >
52
- </ div >
55
+ </ a >
56
+ < div class ="col-md-5 card" data-mf =" false ">
57
+ < div class ="card-body ">
58
+ < h3 class =" card-title " style =" display: flex; align-items: center; gap: 5px; " >
59
+ {{- if $brandIcon -}}
60
+ < img class =" card-img-top " src =" {{ .Site.BaseURL }}/images/icons/{{ $brandIcon }} " />
61
+ {{- else -}}
62
+ < i class =" fas fa-file-alt fa-lg card-img-top " > </ i >
63
+ {{- end -}}
64
+ {{- if ( $title) -}}
65
+ < a href =" {{- $titleUrl -}} " > {{- $title -}} </ a >
66
+ {{- else - }}
67
+ {{ errorf "Old theme: Missing param 'title'" }}
68
+ {{- end -}}
69
+ </ h3 >
70
+ < p > {{- .Inner -}} </ p >
53
71
</ div >
72
+ </ div >
54
73
{{- else -}}
55
74
{{ errorf "The '< card > ' must be nested directly inside the shortcode '< card-section > '. Please see the exampleSite for an example of usage." }}
56
75
{{- end -}}
0 commit comments