Omphaloskepsis-2/layouts/partials/cv/organisation/get-num-of-items.html.tmpl
2024-02-04 01:40:15 +00:00

38 lines
1.3 KiB
Cheetah

<!--
Return the number of a certain type of items an organisation has.
@params sc Site context.
@params section_title Title of the sub-section to show (e.g. "Blog Posts").
@params organisation_titles `dict` of organsation titles for this org and all of its children.
-->
{{- $sc := .sc -}}
{{- $section_title := .section_title -}}
{{- $organisation_titles := .organisation_titles -}}
{{- $icon := dict
"Roles" "🔨"
"Blog Posts" "📌"
"Web Sites" "✉"
"Programs" "P"
"Writings" "🖉"
"Audiovisuals" "AV"
"Others" "?"
"Qualifications" "Q"
"Awards" "A"
"Appearances" "ME"
-}}
{{- $section_items := default
( where ( where $sc.Site.Pages "Section" "blog" ) "Parent.Title" $section_title )
( default
( where ( where $sc.Site.Pages "Section" "cv" ) "Parent.Title" $section_title )
( where ( where $sc.Site.Pages "Section" "portfolio" ) "Parent.Title" $section_title )
)
-}}
{{- $organisation_items := where $section_items ".Params.organisations" "intersect" $organisation_titles -}}
<span class="organisations-table__items-icon{{- if ( eq ( len $organisation_items ) 0 ) }} organisations-table__items-icon--none{{- end -}}">
{{- index $icon $section_title -}} <br>
{{- ( len $organisation_items ) -}}
</span>