This commit is contained in:
Ben Goldsworthy 2024-04-02 20:36:21 +01:00
parent 187900fd5b
commit 1fd9adcb52
No known key found for this signature in database
23 changed files with 1800 additions and 98 deletions

View file

@ -0,0 +1,11 @@
<!--
Given a top-level section title slug [blog|cv|portfolio], returns all
`Pages` within that top-level section.
@param sc The site content (`$`)
@param section_slug The slug of the section to use [blog|cv|portfolio]
@returns Pages|nil
-->
{{- where ( ( .sc.GetPage "cv" ).Sections ) "Title" .section_title -}}

View file

@ -0,0 +1,14 @@
{{- $locations := .Params.location }}
{{- $location := .Params.location }}
{{- range $k, $v := $locations -}}
{{- if ( isset $v "lat" ) -}}
{{- partialCached "util/get_location_by_index.html" ( dict "locations" $v "location" $location ) $location -}}
{{- else if ( eq $k $location ) -}}
{{- with $v -}}
{{- return . -}}
{{- else -}}
{{- warnf "Location %q has no co-ordinates set" $k -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,18 @@
<!--
Returns all locations from `data/locations.json`.
@params locations dict<dict>
@returns dict<dict>
-->
{{- $locations := ( dict ) -}}
{{- range $k, $v := . -}}
{{- if ( isset $v "lat" ) -}}
{{- $locations = merge $locations ( dict $k $v ) -}}
{{- else -}}
{{- $locations = merge $locations ( partial "util/get_location_leaf_nodes.html.tmpl" . ) -}}
{{- end -}}
{{- end -}}
{{- return $locations -}}

View file

@ -0,0 +1,7 @@
<!--
Returns a list of valid values for the `rel` HTML attribute.
@returns slice
-->
{{- return slice "alternate" "author" "external" "help" "license" "me" "next" "nofollow" "noopener" "noreferrer" "opener" "prev" "privacy-policy" "search" "tag" "terms-of-service" -}}

View file

@ -0,0 +1,56 @@
<!--
Recursively render an ordered or unordered list from a set of arbitrarily-
deeply-nested items.
@params sc Site context
@params pc Page context
@params items Set of items to render a list from.
@params schemaType Schema.org type to apply. Optional.
@params listType "unordered" or "ordered". Default "unordered".
-->
<!-- Validation -->
{{- if not .sc.Site.Data.itemtypes -}}
{{- errorf "Can't access site context in partial (%q)" .pc.File.Path -}}
{{- end -}}
{{- if not .items -}}
{{- warnf "No items passed to list partial (%q)" .pc.File.Path -}}
{{- end -}}
{{- if ( and .schemaType ( not ( in .sc.Site.Data.itemtypes .schemaType ) ) ) -}}
{{- erroridf "invalid-schemaType" "Invalid Schema.org type value %q (%q)" .schemaType .pc.File.Path -}}
{{- end -}}
{{- if ( and .listType ( not ( in ( slice "unordered" "ordered" ) .listType ) ) ) -}}
{{- erroridf "invalid-listType" "Invalid list type value %q (%q)" .listType .pc.File.Path -}}
{{- end -}}
<!-- Default Assignment -->
{{- $schemaType := default "" .schemaType -}}
{{- $listType := default "unordered" .listType -}}
<!-- Rendering -->
{{- if ( eq $listType "unordered" ) -}}
<ul>
{{- else -}}
<ol>
{{- end -}}
{{- range $k, $v := .items -}}
<li itemscope itemtype="https://schema.org/Place">
{{- $k -}}
{{- if ( not ( isset $v "lat" ) ) -}}
{{- partial "util/render_recursive_list.html.tmpl" ( dict "sc" $.sc "pc" $.pc "items" $v "schemaType" $schemaType "listType" $listType ) -}}
{{- end -}}
</li>
{{- end -}}
{{- if ( eq $listType "unordered" ) -}}
</ul>
{{- else -}}
</ol>
{{- end -}}