use common *.baseof.html templates

This commit is contained in:
Ben Goldsworthy 2025-06-06 17:01:20 +02:00
parent 4e67efab84
commit af68a0e22d
No known key found for this signature in database
19 changed files with 486 additions and 408 deletions

View file

@ -0,0 +1,60 @@
{{- /*
Renders an organisation's roles in a timeline.
@params sc Site context.
@params pc Page context.
@params organisation_titles Post organisation titles.
*/
-}}
<!-- Validation -->
{{- if ( not ( isset . "sc" ) ) -}}
{{- errorf "No site context passed" -}}
{{- end -}}
{{- if ( not ( isset . "pc" ) ) -}}
{{- errorf "No page context passed" -}}
{{- end -}}
{{- if ( not ( isset . "organisation_titles" ) ) -}}
{{- errorf "No organisation_titles defined (%q)" .pc.Page.File.Path -}}
{{- end -}}
{{- $roles := slice -}}
<!-- Rendering -->
{{- with ( .pc.GetPage "cv/roles" ).Pages -}}
{{- range ( where . "Params.organisations" "intersect" $.organisation_titles ) -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.sc.Site.Params.redact "show" ) ) ) -}}
{{-
$roles = $roles | append (
printf `["%s", "%s", "%s", %s, %s]`
(
partialCached
"cv/organisation/get_role_organisation_string.html"
( dict "sc" $.sc "pc" . )
.
)
(
partialCached
"cv/organisation/get_role_role_string.html"
( dict "sc" $.sc "pc" . )
.
)
(
partialCached
"cv/organisation/get_role_colour.html"
( dict "end_date" .Params.end_date "is_paid" .Params.paid )
.Params.end_date .Params.paid
)
( partialCached "cv/organisation/get_role_start_date.html" .Date .Date )
( partialCached "cv/organisation/get_role_end_date.html" .Params.end_date .Params.end_date )
)
-}}
{{- end -}}
{{- end -}}
{{ end -}}
{{- return ( delimit $roles ", ") -}}

View file

@ -25,9 +25,9 @@
id="{{ .Title | urlize }}"
class="h-entry u-url link--tile"
href="{{ .RelPermalink }}"
itemprop="blogPost"
itemprop="{{- ( $.GetPage .Section ).Params.itemsProp -}}"
itemscope
itemtype="https://schema.org/BlogPosting"
itemtype="https://schema.org/{{- default "CreativeWork" ( $.GetPage .Section ).Params.itemsType -}}"
>
<article
class="item-tile lazy {{- with .Params.site }}item-tile--{{ . }}{{ end -}}"

View file

@ -0,0 +1,57 @@
{{- /*
Renders a post's locations on a map.
@params sc Site context.
@params pc Page context.
@params organisation_titles Post organisation titles.
*/
-}}
<!-- Validation -->
{{- if ( not ( isset . "sc" ) ) -}}
{{- errorf "No site context passed" -}}
{{- end -}}
{{- if ( not ( isset . "pc" ) ) -}}
{{- errorf "No page context passed" -}}
{{- end -}}
{{- if ( not ( isset . "organisation_titles" ) ) -}}
{{- errorf "No organisation_titles defined" -}}
{{- end -}}
<!-- Rendering -->
<script>
google.charts.load('current', {'packages':['timeline']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Type' });
dataTable.addColumn({ type: 'string', id: 'Job Title' });
dataTable.addColumn({ type: 'string', id: 'style', role: 'style' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
{{- partial "cv/organisation/get_organisation_roles_for_chart.html" ( dict "sc" .sc "pc" .pc "organisation_titles" .organisation_titles ) | safeJS -}}
]);
var options = {
title: '{{ .pc.Title | plainify }} Roles Timeline',
height: '100%',
chartArea: {
width: '94%'
},
width: '100%',
timeline: { showBarLabels: true }
};
chart.draw(dataTable, options);
}
</script>

View file

@ -23,24 +23,22 @@
<!-- Rendering -->
<script>
var map = L.map('map').setView([55, -3], 13);
var map = L.map('map').setView([55, -3], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var latLons = [];
{{ $locations_leaf_nodes := partialCached "util/get_location_leaf_nodes.html" .locations_data -}}
{{- range .locations -}}
{{- with ( index $locations_leaf_nodes ( replaceRE `, [A-Z]+` "" . ) ) -}}
L.marker([{{ .lat }}, {{ .lon }}]).addTo(map);
latLons.push([{{ .lat }}, {{ .lon }}]);
{{- else -}}
{{- erroridf "missing-lat-lon" "Could not find lat-lon for %q" . -}}
{{- end -}}
{{- end }}
var latLons = [];
{{ $locations_leaf_nodes := partialCached "util/get_location_leaf_nodes.html" .locations_data -}}
{{- range .locations -}}
{{- with ( index $locations_leaf_nodes ( replaceRE `, [A-Z]+` "" . ) ) -}}
L.marker([{{ .lat }}, {{ .lon }}]).addTo(map);
latLons.push([{{ .lat }}, {{ .lon }}]);
{{- else -}}
{{- erroridf "missing-lat-lon" "Could not find lat-lon for %q" . -}}
{{- end -}}
{{- end }}
map.fitBounds(latLons);
</script>
map.fitBounds(latLons);

View file

@ -43,14 +43,12 @@
{{ if .pc.HasShortcode "chart" }}
{{- $configJs := ( .pc.Page.Resources.GetMatch "charts-init" | fingerprint ) -}}
<script>
{{-
(
partialCached
"scripts/charts.js"
$configJs
$configJs
) | safeJS
)
-}}
</script>
{{ end }}

View file

@ -9,16 +9,16 @@
itemtype="https://schema.org/Blog"
>
<head>
<!-- Meta -->
{{- partialCached "head/meta.html" . -}}
<meta
name="description"
content="{{- block "head-description" . -}}{{- $.Site.Params.description | html -}}{{- end -}}"
content="{{- block "head-description" . -}}{{- $.Site.Params.description | plainify -}}{{- end -}}"
/>
{{- block "title" . -}}
{{- partialCached "head/title.html" ( slice .Site.Title .Site.Params.tagline ) .Site.Title .Site.Params.tagline -}}
{{- partialCached "head/title.html" ( slice ( .Page.Title | plainify ) .Site.Title ) .Site.Title .Page.Title -}}
{{- end -}}
<!-- References -->

106
layouts/baseof.section.html Normal file
View file

@ -0,0 +1,106 @@
<!DOCTYPE html>
{{ partialCached "copying.html" . }}
<html
class="h-card"
lang="en-gb"
itemscope
itemtype="https://schema.org/WebSite"
>
<head>
<!-- Meta -->
{{- partialCached "head/meta.html" . -}}
<meta
name="description"
content="{{- block "head-description" . -}}{{- .Summary | plainify -}}{{- end -}}"
/>
{{- block "title" . -}}
{{- partialCached "head/title.html" ( slice ( .Page.Title | plainify ) .Site.Title ) .Site.Title .Page.Title -}}
{{- end -}}
<!-- References -->
{{- partialCached "head/references.html" ( dict "sc" $ "pc" . ) -}}
<link
rel="canonical"
href="{{- .Permalink -}}"
/>
{{- with .OutputFormats.Get "rss" -}}
<link
rel="{{ .Rel }}"
type="{{ .MediaType.Type | html }}"
href="{{ .RelPermalink }}"
title="{{ $.Site.Title | safeHTML }}"
/>
{{- end -}}
<!-- Stylesheets -->
{{- partialCached "head/stylesheets.html" . -}}
<!-- Optional Includes -->
{{- if .Param "math" -}}
{{- partialCached "head/math.html" . -}}
{{- end -}}
{{- block "header-scripts" . -}}<!-- -->{{- end -}}
{{- block "header-styles" . -}}<!-- -->{{- end -}}
</head>
<body class="site-container site-container{{ block "main-class" . }} layouts-default-baseof layouts-default-baseof-section{{ end }}">
{{- block "header" . -}}
{{- partialCached "header/site-header.html" . -}}
{{- end -}}
<article
class="{{ block "article-class" . }}h-entry {{ end }} site-content site-content{{ block "main-class" . }}{{ end }}"
itemscope
itemtype="https://schema.org/{{- default "Collection" .Params.mainType -}}"
>
{{ block "main-header" . }}
<header class="site-content__header">
<h2 class="page-title">{{ .Title | safeHTML }}
{{ range .AlternativeOutputFormats -}}
<a href="{{ .RelPermalink }}" aria-label="{{ $.Title }} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{ $.Site.Params.feedIcon }}">
</a>
{{- end -}}
</h2>
{{- .Content -}}
<nav class="page-header__minor-links">
{{ partial "years-list.html" . }}
</nav>
</header>
{{ end }}
{{ block "main-body" . }}
{{- partial "items-grid.html" . -}}
{{ end }}
{{ block "main-footer" . }}{{ end }}
</article>
{{- block "footer" . -}}
<footer class="site-footer">
{{-
partialCached
"footer/text.html"
( dict
"author_name" .Site.Params.Author.name
"report_issue_url" ( printf "%s%s" .Site.Params.codeURL .Site.Params.reportIssueURL )
"privacy_policy_url" ( relref . "privacy-policy" )
"sitemap_path" ( printf "/%s" .Sitemap.Filename )
"last_build_time" ( now.Format "2006-01-02T15:04:05" )
)
-}}
{{ block "footer-scripts" . }}
<script src="/js/lazy-images.js"></script>
{{ end }}
</footer>
{{- end -}}
</body>
</html>

138
layouts/baseof.single.html Normal file
View file

@ -0,0 +1,138 @@
<!DOCTYPE html>
{{ partialCached "copying.html" . }}
<html
class="h-card"
lang="en-gb"
itemscope
itemtype="https://schema.org/Blog"
>
<head>
<!-- Meta -->
{{- partialCached "head/meta.html" . -}}
<meta
name="description"
content="{{- block "head-description" . -}}{{- .Summary | plainify -}}{{- end -}}"
/>
{{- block "title" . -}}
{{- partialCached "head/title.html" ( slice ( .Page.Title | plainify ) .Site.Title ) .Site.Title .Page.Title -}}
{{- end -}}
<!-- References -->
{{- partialCached "head/references.html" ( dict "sc" $ "pc" . ) -}}
<link
rel="canonical"
href="{{- .Permalink -}}"
/>
{{- with .OutputFormats.Get "rss" -}}
<link
rel="{{ .Rel }}"
type="{{ .MediaType.Type | html }}"
href="{{ .RelPermalink }}"
title="{{ $.Site.Title | safeHTML }}"
/>
{{- end -}}
<!-- Stylesheets -->
{{- partialCached "head/stylesheets.html" . -}}
<!-- Optional Includes -->
{{- if .Param "math" -}}
{{- partialCached "head/math.html" . -}}
{{- end -}}
{{- block "header-scripts" . -}}
{{ with .Params.locations }}
<script
id="Map-script"
src="/js/leaflet/leaflet.js"
></script>
{{ end }}
{{- end -}}
{{- block "header-styles" . -}}
{{ with .Params.styles }}
<link
rel="stylesheet"
type="text/css"
href="{{- ( $.Page.Resources.GetMatch "style" ).RelPermalink -}}"
/>
{{ end }}
{{ with .Params.locations }}
<link
rel="stylesheet"
href="/css/leaflet/leaflet.css"
/>
{{ end }}
{{- end -}}
</head>
<body class="site-container site-container {{ block "main-class" . }}layouts-default-baseof layouts-default-baseof-single{{ end }}">
{{- block "header" . -}}
{{- partialCached "header/site-header.html" . -}}
{{- end -}}
<article
class="{{ block "article-class" . }}h-entry{{ end }}site-content site-content{{ block "main-class" . }}{{ end }}"
itemscope
itemtype="https://schema.org/BlogPosting"
>
{{ block "main-header" . }}
{{- partial "single/main-header.html" ( dict "pc" . "sc" $ ) -}}
{{ end }}
{{ block "main-body" . }}
<section class="site-content__body">
{{- with .Summary -}}
<section
class="article-body__summary"
itemprop="abstract"
>
<h2>Summary</h2>
<p class="p-summary">{{- . -}}</p>
</section>
{{ end }}
{{- if ( or .Params.internal_links .Params.external_links ) -}}
{{- partial "single/main-body/links.html" ( dict "pc" . "sc" $ ) -}}
{{- end -}}
{{- partial "single/main-body/content.html" ( dict "pc" . "sc" $ ) -}}
{{ block "main-body-additional" . }}<!-- -->{{ end }}
</section>
{{- with .Page.Resources.Get "comments.md" -}}
{{- partial "single/main-body/comments.html" ( dict "pc" . "sc" $ ) -}}
{{- end -}}
{{ end }}
{{ block "main-footer" . }}
{{- partial "single/post-meta.html" ( dict "pc" . "sc" $ ) -}}
{{ end }}
</article>
{{- block "footer" . -}}
<footer class="site-footer">
{{-
partialCached
"footer/text.html"
( dict
"author_name" .Site.Params.Author.name
"report_issue_url" ( printf "%s%s" .Site.Params.codeURL .Site.Params.reportIssueURL )
"privacy_policy_url" ( relref . "privacy-policy" )
"sitemap_path" ( printf "/%s" .Sitemap.Filename )
"last_build_time" ( now.Format "2006-01-02T15:04:05" )
)
-}}
{{ block "footer-scripts" . }}
{{- partialCached "single/footer-scripts.html" ( dict "pc" . "sc" $ ) . -}}
{{ end }}
</footer>
{{- end -}}
</body>
</html>

View file

@ -1,11 +1,5 @@
{{ define "main-class" }}--section layouts-blog-section{{ end }}
{{ define "main-type" }}{{ .Params.mainType }}{{ end }}
{{ define "footer-scripts" }}
<script src="/js/lazy-images.js"></script>
{{ end }}
{{ define "main-header" }}
<header class="site-content__header">
<h2 class="page-title">
@ -40,8 +34,8 @@
{{ end }}
{{ end }}
</h2>
{{ .Content }}
{{ .Content }}
<nav class="page-header__minor-links">
<ul class="minor-links__categories">
@ -56,6 +50,7 @@
</li>
{{ end }}
</ul>
{{ if eq .Type "blog" }}
{{ with .GetPage "blog/posts" }}
{{ partial "years-list.html" . }}
@ -68,11 +63,11 @@
{{ end }}
{{ define "main-body" }}
{{ if eq .Type "blog" }}
{{ with .GetPage "blog/posts" }}
{{ partial "items-grid.html" . }}
{{ end }}
{{ else }}
{{ partial "items-grid.html" . }}
{{ end }}
{{- if eq .Type "blog" -}}
{{- with .GetPage "blog/posts" -}}
{{- partial "items-grid.html" . -}}
{{- end -}}
{{- else -}}
{{- partial "items-grid.html" . -}}
{{- end -}}
{{ end }}

View file

@ -4,57 +4,7 @@
{{ define "main-class" }}--single layouts-blog-single{{ end }}
{{ define "header-scripts" }}
{{ with .Params.locations }}
<script
id="Map-script"
src="/js/leaflet/leaflet.js"
></script>
{{ end }}
{{ end }}
{{ define "header-styles" }}
{{ with .Params.styles }}
<link
rel="stylesheet"
type="text/css"
href="{{ ( $.Page.Resources.GetMatch "style").RelPermalink }}"
/>
{{ end }}
{{ with .Params.locations }}
<link
rel="stylesheet"
href="/css/leaflet/leaflet.css"
/>
{{ end }}
{{ end }}
{{ define "footer-scripts" }}
{{- partialCached "single/footer-scripts.html" ( dict "pc" . "sc" $ ) . -}}
{{ end }}
{{ define "main-header" }}
{{- partial "single/main-header.html" ( dict "pc" . "sc" $ ) -}}
{{ end }}
{{ define "main-body" }}
<section class="site-content__body">
{{ with .Summary }}
<section
class="article-body__summary"
itemprop="abstract"
>
<h2>Summary</h2>
<p class="p-summary">{{ . }}</p>
</section>
{{ end }}
{{- if ( or .Params.internal_links .Params.external_links ) -}}
{{- partial "single/main-body/links.html" ( dict "pc" . "sc" $ ) -}}
{{- end -}}
{{- partial "single/main-body/content.html" ( dict "pc" . "sc" $ ) -}}
{{ define "main-body-additional" }}
{{ if fileExists ( path.Join $.Page.File.Dir "appendices.md" ) }}
{{- partial "single/main-body/appendices.html" ( dict "pc" . "sc" $ ) -}}
{{ end }}
@ -62,13 +12,4 @@
{{ if fileExists ( path.Join $.Page.File.Dir "corrigendum.md" ) }}
{{- partial "single/main-body/appendices.html" ( dict "pc" . "sc" $ ) -}}
{{ end }}
</section>
{{ with .Page.Resources.Get "comments.md" }}
{{- partial "single/main-body/comments.html" ( dict "pc" . "sc" $ ) -}}
{{ end }}
{{ end }}
{{ define "main-footer" }}
{{ partial "single/post-meta.html" ( dict "pc" . "sc" $ ) }}
{{ end }}

45
layouts/cv/cv.html Normal file
View file

@ -0,0 +1,45 @@
{{ define "main-class" }}--section layouts-cv-cv{{ end }}
{{ define "header-scripts" }}
{{ if ( or ( eq .Type "cv" ) ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
<script id="Google-Charts-script" src="/js/google-charts/google-charts.js"></script>
{{ end }}
{{ end }}
{{ define "footer-scripts" }}
{{ if ( not ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
{{ $js := resources.Get "js/roles-chart.js" | resources.ExecuteAsTemplate "/js/render-roles-timeline.js" ( .GetPage "cv/roles" ) | resources.Fingerprint }}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- end -}}
{{ end }}
{{ define "main-header" }}
<header class="site-content__header">
<h2 class="page-title">{{- .Title | safeHTML -}}. {{ if not ( or ( eq .Type "cv" ) ( eq .Type "cv/organisations" ) ) -}}
{{- range .AlternativeOutputFormats -}}
<a href="{{- .RelPermalink -}}" aria-label="{{- $.Title -}} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{- $.Site.Params.feedIcon -}}">
</a>
{{- end -}}
{{- end -}}
</h2>
{{- .Content -}}
<nav class="page-header__minor-links">
<ul>
{{- range ( where .Sections "Type" "not in" ( slice "cv/roles" ) ).ByTitle }}
<li><a href="{{- .RelPermalink -}}"><h3>{{- .Title -}}</h3></a> <p>({{- len (where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) -}})</p></li>
{{- end -}}
</ul>
</nav>
{{- partialCached "cv/timeline-legend.html" . -}}
</header>
{{ end }}
{{ define "main-body" }}
<article class="site-content__body site-content__body--chart">
<div id="timeline" aria-label="Roles timeline" role="img" height="70vh">Javascript must be enabled to view this chart.</div>
</article>
{{ end }}

View file

@ -11,68 +11,7 @@
{{ end }}
{{ define "footer-scripts" }}
{{ $titles := .Scratch.Get "titles" }}
<script>
google.charts.load('current', {'packages':['timeline']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Type' });
dataTable.addColumn({ type: 'string', id: 'Job Title' });
dataTable.addColumn({ type: 'string', id: 'style', role: 'style' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
{{- with ( .GetPage "cv/roles" ).Pages -}}
{{- range ( where . ".Params.organisations" "intersect" $titles ) -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
{{-
printf `["%s", "%s", "%s", %s, %s],`
(
partialCached
"cv/organisation/get_role_organisation_string.html"
( dict "sc" $ "pc" . )
.
)
(
partialCached
"cv/organisation/get_role_role_string.html"
( dict "sc" $ "pc" . )
.
)
(
partialCached
"cv/organisation/get_role_colour.html"
( dict "end_date" .Params.end_date "is_paid" .Params.paid )
.Params.end_date .Params.paid
)
( partialCached "cv/organisation/get_role_start_date.html" .Date .Date )
( partialCached "cv/organisation/get_role_end_date.html" .Params.end_date .Params.end_date )
| safeJS
-}}
{{- end -}}
{{- end -}}
{{ end -}}
]);
var options = {
title: '{{ .Title | plainify }} Roles Timeline',
height: '100%',
chartArea: {
width: '94%'
},
width: '100%',
timeline: { showBarLabels: true }
};
chart.draw(dataTable, options);
}
</script>
{{- partial "scripts/show_organisation_roles_in_timeline.js" ( dict "sc" $ "pc" . "organisation_titles" ( .Scratch.Get "titles" ) ) -}}
{{ end }}
{{ define "main-header" }}
@ -139,11 +78,25 @@
{{ partial "cv/organisations/recursive-parents.html" ( dict "c" . "g" $ ) }}
{{- $parents := partial "cv/organisations/reverse-slice.html" ( $.Scratch.Get "parents" ) -}}
{{- range $parents -}}<ul><li class="hierarchy-item hierarchy-item--parent"><a href="{{ .RelPermalink }}">{{ default .Title .Params.markup_title | .Page.RenderString }}</a>{{- end -}}
<ul><li class="hierarchy-item hierarchy-item--current">{{ default .Title .Params.markup_title | .Page.RenderString }}</li>
{{ range .Sections }}<ul>{{ partial "cv/organisations/recursive-children.html" . }}</ul>{{ end }}
</ul>
{{- range $parents -}}</li></ul>{{- end -}}
{{- range $parents -}}
<ul>
<li class="hierarchy-item hierarchy-item--parent">
<a href="{{- .RelPermalink -}}">
{{- default .Title .Params.markup_title | .Page.RenderString -}}
</a>
{{- end -}}
<ul>
<li class="hierarchy-item hierarchy-item--current">
{{- default .Title .Params.markup_title | .Page.RenderString -}}
</li>
{{- range .Sections -}}
<ul>{{- partial "cv/organisations/recursive-children.html" . -}}</ul>
{{- end -}}
</ul>
{{- range $parents -}}
</li>
</ul>
{{- end -}}
</section>
</footer>
{{ end }}

View file

@ -1,112 +1,24 @@
{{ define "main-class" }}
{{- if .IsDescendant ( .GetPage "/cv/organisations" ) -}}--single{{- else -}}--section{{- end }} layouts-cv-section
{{ end }}
{{ define "header-scripts" }}
{{ if ( or ( eq .Type "cv" ) ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
<script id="Google-Charts-script" src="/js/google-charts/google-charts.js"></script>
{{ end }}
{{ end }}
{{ define "footer-scripts" }}
{{ if ( not ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
{{ $js := resources.Get "js/roles-chart.js" | resources.ExecuteAsTemplate "/js/render-roles-timeline.js" ( .GetPage "cv/roles" ) | resources.Fingerprint }}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- end -}}
{{ end }}
{{ define "main-class" }}--section layouts-cv-section{{ end }}
{{ define "main-header" }}
{{ if .IsDescendant ( .GetPage "/cv/organisations" ) }}
<header class="site-content__header">
<div class="article-header__featured-image article-header__featured-image--fit"
{{- with .Params.featured_image -}}
{{- with ( $.Resources.GetMatch . ) -}}
style="background-image: url({{- partialCached "images/get-image.html" ( dict "img" . ) .Title -}}){{ with .Params.bg -}}; background-color: {{ . -}};{{- end -}}"
{{- else -}}
{{- errorf "No Page Resource found for src '%q' (%q).\n\n\tAvailable Page Resources are:\n\t\t%v" . $.pc.Page.File.Path $.pc.Page.Resources -}}
{{- end -}}
{{- end -}}
>
<div class="article-header__title-wrapper{{ if .Params.title_in_logo }} article-header__title-wrapper--no-title{{ end }}">
<h2 class="article-header__title">{{ default .Title .Params.markup_title | .Page.RenderString }}</h2>
</div>
</div>
{{- with .Params.nka -}}<p>Now known as: {{ . }}</p>{{- end -}}
{{- with .Params.fka -}}<p>Formerly known as: {{ . }}</p>{{- end -}}
{{- with .Params.tka -}}<p>Then known as: {{ . }}</p>{{- end -}}
</header>
{{ else }}
<header class="site-content__header">
<h2 class="page-title">{{ .Title | safeHTML }}. {{ if not ( or ( eq .Type "cv" ) ( eq .Type "cv/organisations" ) ) -}}
{{- range .AlternativeOutputFormats -}}
<a href="{{ .RelPermalink }}" aria-label="{{ $.Title }} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{ $.Site.Params.feedIcon }}">
</a>
{{- end -}}
<header class="site-content__header">
<h2 class="page-title">{{ .Title | safeHTML }}. {{ if not ( or ( eq .Type "cv" ) ( eq .Type "cv/organisations" ) ) -}}
{{- range .AlternativeOutputFormats -}}
<a href="{{ .RelPermalink }}" aria-label="{{ $.Title }} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{ $.Site.Params.feedIcon }}">
</a>
{{- end -}}
</h2>
{{- .Content -}}
{{- end -}}
</h2>
{{- .Content -}}
{{- if ( and ( eq .Type "cv" ) ( not ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) ) -}}
<nav class="page-header__minor-links">
<ul>
{{ range ( where .Sections "Type" "not in" ( slice "cv/roles" ) ).ByTitle }}
<li><a href="{{ .RelPermalink }}"><h3>{{ .Title }}</h3></a> <p>({{ len (where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) }})</p></li>
{{ end }}
</ul>
</nav>
{{- partialCached "cv/timeline-legend.html" . -}}
{{- else -}}
<nav class="page-header__minor-links">
{{- partial "years-list.html" . -}}
</nav>
{{- end -}}
</header>
{{ end }}
<nav class="page-header__minor-links">
{{- partial "years-list.html" . -}}
</nav>
</header>
{{ end }}
{{ define "main-body" }}
{{ if .IsDescendant ( .GetPage "/cv/organisations" ) }}
{{ $titles := slice ( .Title | plainify ) }}
{{ with .Sections }}
{{ $titles = $titles | append ( partial "cv/organisations/recursive-children-titles.html" . ) }}
{{ end }}
{{ .Scratch.Set "titles" $titles }}
<main class="site-content__body organisation">
{{- partial "cv/organisation/description.html" ( dict "content" .Content ) -}}
{{- partial "cv/organisation/roles-timeline.html" -}}
{{- partial "cv/organisation/related-items.html" ( dict "sc" $ "organisation_titles" ( .Scratch.Get "titles" ) "organisation_title" .Title ) -}}
</main>
{{ else if eq .Type "cv" }}
<article class="site-content__body site-content__body--chart">
<div id="timeline" aria-label="Roles timeline" role="img" height="70vh">Javascript must be enabled to view this chart.</div>
</article>
{{ else }}
{{ partial "items-grid.html" . }}
{{ end }}
{{ end }}
{{ define "main-footer" }}
{{ if .IsDescendant ( .GetPage "/cv/organisations" ) }}
<footer class="site-content__footer">
<section id="hierarchy">
<h3 class="subheading">Hierarchy</h3>
{{ $.Scratch.Set "parents" ( slice ) }}
{{ partial "cv/organisations/recursive-parents.html" ( dict "c" . "g" $ ) }}
{{- $parents := partial "cv/organisations/reverse-slice.html" ( $.Scratch.Get "parents" ) -}}
{{- range $parents -}}<ul><li class="hierarchy-item hierarchy-item--parent"><a href="{{ .RelPermalink }}">{{ default .Title .Params.markup_title | .Page.RenderString }}</a>{{- end -}}
<ul><li class="hierarchy-item hierarchy-item--current">{{ default .Title .Params.markup_title | .Page.RenderString }}</li>
{{ range .Sections }}<ul>{{ partial "cv/organisations/recursive-children.html" . }}</ul>{{ end }}
</ul>
{{- range $parents -}}</li></ul>{{- end -}}
</section>
</footer>
{{ end }}
{{ partial "items-grid.html" . }}
{{ end }}

View file

@ -1,3 +1,7 @@
{{ define "title" }}
{{- partialCached "head/title.html" ( slice .Site.Title .Site.Params.tagline ) .Site.Title .Site.Params.tagline -}}
{{ end }}
{{ define "main-class" }}--homepage{{ end }}
{{ define "header" }} <!-- null --> {{ end }}

View file

@ -1,59 +1,5 @@
{{ define "main-class" }}--section layouts-portfolio-section{{ end }}
{{ define "footer-scripts" }}
<script>
// Source: https://css-tricks.com/the-complete-guide-to-lazy-loading-images/
document.addEventListener("DOMContentLoaded", function() {
var lazyloadImages;
if ("IntersectionObserver" in window) {
lazyloadImages = document.querySelectorAll(".lazy");
var imageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
var image = entry.target;
image.classList.remove("lazy");
imageObserver.unobserve(image);
}
});
});
lazyloadImages.forEach(function(image) {
imageObserver.observe(image);
});
} else {
var lazyloadThrottleTimeout;
lazyloadImages = document.querySelectorAll(".lazy");
function lazyload () {
if(lazyloadThrottleTimeout) {
clearTimeout(lazyloadThrottleTimeout);
}
lazyloadThrottleTimeout = setTimeout(function() {
var scrollTop = window.pageYOffset;
lazyloadImages.forEach(function(img) {
if(img.offsetTop < (window.innerHeight + scrollTop)) {
img.src = img.dataset.src;
img.classList.remove('lazy');
}
});
if(lazyloadImages.length == 0) {
document.removeEventListener("scroll", lazyload);
window.removeEventListener("resize", lazyload);
window.removeEventListener("orientationChange", lazyload);
}
}, 20);
}
document.addEventListener("scroll", lazyload);
window.addEventListener("resize", lazyload);
window.addEventListener("orientationChange", lazyload);
}
});
</script>
{{ end }}
{{ define "main-header" }}
<header class="site-content__header">
<h2 class="page-title">{{ .Title | safeHTML }}.

View file

@ -1,25 +0,0 @@
{{ define "title" }}
{{- partialCached "head/title.html" ( slice ( .Page.Title | plainify ) .Site.Title ) .Site.Title .Page.Title -}}
{{ end }}
{{ define "main-class" }}--section layouts-default-section{{ end }}
{{ define "main-type" }}.{{ .Params.mainType }}{{ end }}
{{ define "item-type" }}{{ .Params.itemsType }}{{ end }}
{{ define "main-header" }}
<header class="site-content__header">
<h2 class="page-title">{{ .Title | safeHTML }}
{{ range .AlternativeOutputFormats -}}
<a href="{{ .RelPermalink }}" aria-label="{{ $.Title }} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{ $.Site.Params.feedIcon }}">
</a>
{{ end }}
</h2>
{{ .Content }}
</header>
{{ end }}
{{ define "main-body" }}
{{ partial "items-grid.html" . }}
{{ end }}

View file

@ -1,54 +0,0 @@
{{ define "title" }}
{{- partialCached "head/title.html" ( slice ( .Page.Title | plainify ) .Site.Title ) .Site.Title .Page.Title -}}
{{ end }}
{{ define "head-description" }}{{ .Summary | plainify }}{{ end }}
{{ define "main-class" }}--single layouts-default-single{{ end }}
{{ define "header-scripts" }}
{{ with .Params.locations }}
<script
id="Map-script"
src="/js/leaflet/leaflet.js"
></script>
{{ end }}
{{ end }}
{{ define "header-styles" }}
{{ with .Params.styles }}
<link
rel="stylesheet"
type="text/css"
href="{{ ( $.Page.Resources.GetMatch "style").RelPermalink }}"
/>
{{ end }}
{{ with .Params.locations }}
<link
rel="stylesheet"
href="/css/leaflet/leaflet.css"
/>
{{ end }}
{{ end }}
{{ define "footer-scripts" }}
{{- partialCached "single/footer-scripts.html" ( dict "pc" . "sc" $ ) . }}
{{ end }}
{{ define "main-header" }}
{{ partial "single/main-header.html" ( dict "pc" . "sc" $ ) }}
{{ end }}
{{ define "main-body" }}
<section class="site-content__body">
{{- if ( or .Params.internal_links .Params.external_links ) -}}
{{- partial "single/main-body/links.html" ( dict "pc" . "sc" $ ) -}}
{{- end -}}
{{- partial "single/main-body/content.html" ( dict "pc" . "sc" $ ) -}}
</section>
{{ end }}
{{ define "main-footer" }}
{{ partial "single/post-meta.html" ( dict "pc" . "sc" $ ) }}
{{ end }}