refactor templates layout

@see https://gohugo.io/templates/new-templatesystem-overview/
This commit is contained in:
Ben Goldsworthy 2025-06-06 15:36:06 +02:00
parent a83f339dc8
commit 230c46411b
No known key found for this signature in database
102 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,83 @@
<!--
Renders the table list of organisations.
-->
<section class="site-content__body">
<table class="organisations-table">
<thead>
<tr>
<th colspan="2">Organisation</th>
<th>Children</th>
<th>Related Items</th>
</tr>
</thead>
<tbody>
{{- range .Pages -}}
{{- $organisation_title := .Title -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
{{ $organisation_titles := slice ( $organisation_title | plainify ) }}
{{ with .Sections }}
{{ $organisation_titles = $organisation_titles | append ( partial "cv/organisations/recursive-children-titles.html" . ) }}
{{ end }}
<tr>
<td>
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
{{- partialCached "redact-black.html" . -}}
{{- end -}}
{{- else -}}
{{- if .Params.featured_image -}}
{{- with .Resources.GetMatch .Params.featured_image -}}
<img class="organisations-table__logo" loading="lazy" src="{{- .RelPermalink -}}" {{ with .Params.bg }}style="background-color: {{ . }}"{{ end }}>
{{- else -}}
<img class="organisations-table__logo" loading="lazy" src="{{- .Params.featured_image -}}">
{{- end -}}
{{- end -}}
{{- end -}}
</td>
<td>
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
{{- partialCached "redact-black.html" . -}}
{{- end -}}
{{- else -}}
<a href="{{ .RelPermalink }}">
{{- if .Params.TitleLang -}}<i lang="{{ .Params.TitleLang }}" title="{{ .Params.TitleTrans }}"}>{{- end -}}
{{- with .Params.markup_title -}}{{- . | $.Page.RenderString -}}{{- else -}}{{- $organisation_title | $.Page.RenderString -}}{{- end -}}
{{- if .Params.TitleLang -}}</i>{{- end -}}
</a>
{{- end -}}
</td>
<td>
<span class="organisations-table__items-icon{{- if ( eq ( len .Sections ) 0 ) }} organisations-table__items-icon--none{{- end -}}">
🧑‍🧒 <br>
{{- len .Sections -}}
</span>
</td>
<td>
{{- range slice
"Roles"
"Blog Posts"
"Web Sites"
"Programs"
"Writings"
"Audiovisuals"
"Others"
"Qualifications"
"Awards"
"Appearances"
-}}
{{- partialCached "cv/organisation/get-num-of-items.html" ( dict "sc" $ "section_title" . "organisation_titles" $organisation_titles ) ( print $organisation_title "_" . ) -}}
{{- end -}}
</td>
</tr>
{{- end -}}
{{- end -}}
</tbody>
</table>
</section>

View file

@ -0,0 +1,10 @@
{{ $titles := ( slice ) }}
{{ range . }}
{{ $titles = $titles | append (slice ( .Title | plainify ) ) }}
{{ if .Sections }}
{{ $titles = $titles | append ( partial "cv/organisations/recursive-children-titles.html" .Sections ) }}
{{ end }}
{{ end }}
{{ return $titles }}

View file

@ -0,0 +1,18 @@
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
<li class="hierarchy-item hierarchy-item--child">
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
{{- partialCached "redact-black.html" . -}}
{{- end -}}
{{- else -}}
<a href="{{- .RelPermalink -}}">
{{- default .Title .Params.markup_title | .Page.RenderString -}}
</a>
{{- range .Sections -}}
<ul>
{{- partial "cv/organisations/recursive-children.html" . -}}
</ul>
{{- end -}}
{{- end -}}
</li>
{{- end -}}

View file

@ -0,0 +1,12 @@
<!--. is .c-->
<!--$ is .g-->
{{ $scratch := .g.Scratch }}
{{ if .c.Parent }}
{{ if ne .c.Parent.Type "cv/organisations" }}
{{ with .c.Parent }}
{{ $scratch.Add "parents" ( slice . ) }}
{{ partial "cv/organisations/recursive-parents.html" (dict "c" . "g" $.g ) }}
{{ end }}
{{ end }}
{{ end }}

View file

@ -0,0 +1,9 @@
<!-- Source: https://discourse.gohugo.io/t/reverse-array/28753/2 -->
{{- $sliceOriginal := . -}}
{{- $len := len $sliceOriginal -}}
{{- $sliceReversed := slice -}}
{{- range seq $len -}}
{{- $sliceReversed = $sliceReversed | append (index $sliceOriginal (sub $len .)) }}
{{- end -}}
{{- return $sliceReversed -}}