update
This commit is contained in:
parent
187900fd5b
commit
1fd9adcb52
23 changed files with 1800 additions and 98 deletions
11
layouts/partials/util/get_content_by_section.html
Normal file
11
layouts/partials/util/get_content_by_section.html
Normal 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 -}}
|
14
layouts/partials/util/get_location_by_index.html
Normal file
14
layouts/partials/util/get_location_by_index.html
Normal 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 -}}
|
18
layouts/partials/util/get_location_leaf_nodes.html.tmpl
Normal file
18
layouts/partials/util/get_location_leaf_nodes.html.tmpl
Normal 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 -}}
|
7
layouts/partials/util/get_valid_rel_values.html.tmpl
Normal file
7
layouts/partials/util/get_valid_rel_values.html.tmpl
Normal 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" -}}
|
56
layouts/partials/util/render_recursive_list.html.tmpl
Normal file
56
layouts/partials/util/render_recursive_list.html.tmpl
Normal 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 -}}
|
Loading…
Add table
Add a link
Reference in a new issue