Home: Add columns feature

This commit is contained in:
jtbx 2023-10-17 22:52:36 +02:00
commit 49e0179832
4 changed files with 77 additions and 7 deletions

View file

@ -24,16 +24,34 @@
{{- end }}
{{- $home := .Site.GetPage "/home" }}
{{- range sort ($home.Resources.ByType "page") "File.Path" "asc" }}
{{- $sections := where ($home.Resources.ByType "page") ".File.LogicalName" "index.md" }}
{{- range sort $sections "File.Path" "asc" }}
<div class="section">
<h2>{{ .Title }}</h2>
{{ .Content -}}
{{- $sec := .CurrentSection }}
{{- $subsec_dir := strings.TrimLeft "home/" .File.Dir }}
{{- $subsec_glob := printf "%s*.md" (strings.TrimLeft "home/" .File.Dir) }}
{{- $subsecs := where ($home.Resources.Match $subsec_glob) ".File.LogicalName" "!=" "index.md" }}
{{- if $subsecs }}
<div class="flex-grid">
{{- range $subsecs }}
<div class="wide">
<h4>{{ .Title }}</h4>
{{- $img_path := printf "%s%s" $subsec_dir .Params.Image }}
{{- with $home.Resources.Get $img_path }}
<img class="groups-img" src="{{ .Permalink }}">
{{- end }}
{{ .Content }}
</div>
{{- end }}
</div>
{{- end }}
{{- with .Params.Resources }}
<div class="flex-grid">
{{- range . }}
{{- $img := $sec.Resources.GetMatch (printf "*/%s" .src) }}
{{- $img := $home.Resources.GetMatch (printf "*/%s" .src) }}
<div class="img-link"><a href="{{ .params.url }}"><img src="{{ $img.Permalink }}" class="box-image" alt=""></a></div>
{{- end }}
</div>

View file

@ -6,9 +6,13 @@
{{- $page := .Page }}
{{- if not $isBundle }}
{{ $page_dir := path.Dir .Page.File }}
{{ $pagebundle_path := path.Join "/" $page_dir }}
{{ $page_dir := path.Dir .Page.File }}
{{ $pagebundle_path := path.Join "/" $page_dir }}
{{ $page = .Site.GetPage $pagebundle_path }}
{{- if not $page.IsPage }}
{{ $pagebundle_path := path.Join "/" .Page.Section }}
{{ $page = .Site.GetPage $pagebundle_path }}
{{- end -}}
{{- end -}}
{{- with $page.Resources.Get $imagename }}