Skip to content

Commit 1df645c

Browse files
committed
Landing: Added new shortcodes + partials to support custom landing page
1 parent 99559e9 commit 1df645c

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

layouts/_default/list.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@
2929
{{ end }}
3030
</section>
3131
<h1>{{ .Title }}</h1>
32-
{{ .Content }}
3332

3433
{{ partial "banner" . }}
3534

3635
{{ if (lt .WordCount 1) }}
36+
{{ .Content }}
3737
{{ range .Pages.ByWeight }}
3838
<h2>
3939
<a href="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}}">{{ .Title }}</a>
4040
</h2>
4141
{{ end }}
42+
{{ else }}
43+
{{ partial "custom-landing-page" . }}
4244
{{end}}
4345

4446
<hr>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 }}
11+
{{ end }}
12+
{{ end }}
13+
{{ .Content }}

layouts/shortcodes/card-layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{- .Inner | markdownify -}}

layouts/shortcodes/card-section.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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>

layouts/shortcodes/card.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- $current := .Page.Scratch.Get "cards" | default (slice) -}}
2+
{{- $newCard := dict "title" (.Get "title") "content" (.Inner) -}}
3+
{{- .Page.Scratch.Set "cards" ($current | append $newCard) -}}
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>

0 commit comments

Comments
 (0)