update theme

This commit is contained in:
Ben Goldsworthy 2023-08-22 11:14:33 +01:00
parent 920db1a5ce
commit 43ddb22f80
17 changed files with 1462 additions and 207 deletions

View file

@ -6,11 +6,10 @@
class="figure--blockquote blockquote{{- if .Params.style }} blockquote--{{- .Params.style -}}{{- end -}}"
itemscope
itemtype="Quotation"
>
role="group">
<blockquote
class="blockquote__body"
{{- if .Params.cite }} cite="{{ .Params.cite }}"{{- end -}}
>
{{- if .Params.cite }} cite="{{ .Params.cite }}"{{- end -}}>
{{- .Inner | .Page.RenderString -}}
</blockquote>
<figcaption class="blockquote__caption">
@ -25,6 +24,7 @@
{{- .Scratch.SetInMap "Params" "titleTr" .Params.titleSeriesTr -}}
{{- .Scratch.SetInMap "Params" "cite" .Params.citeSeries -}}
{{- .Scratch.SetInMap "Params" "schemaType" .Params.schemaTypeSeries -}}
{{- .Scratch.SetInMap "Params" "suppress" "true" -}}
{{- .Scratch.SetInMap "parentCite" "Params" ( .Scratch.Get "Params" ) -}}
{{- partial "cite.html" ( .Scratch.Get "parentCite" ) -}}
{{- with .Params.numberSeries }}, {{ . | safeHTML -}}{{- end -}}

View file

@ -0,0 +1,19 @@
<figure class="article__figure figure{{ with .Get "class" }} {{ . }}{{ end }}" role="group">
{{- with .Get "chart-id" -}}
<canvas class="figure__chart" id="{{ . }}">
You must enable Javascript to view this chart.
</canvas>
{{- end -}}
{{- with .Get "chart-id-2" -}}
<canvas class="figure__chart" id="{{ . }}">
You must enable Javascript to view this chart.
</canvas>
{{- end -}}
{{- if or ( .Get "caption" ) ( .Get "title" ) -}}
<figcaption class="figure__caption{{ if not ( or ( .Get "caption" ) ( .Get "title" ) ) }} figure__caption--no-height{{ end }}">
{{- with .Get "title" -}}<h4 class="figcaption__title">{{ . | markdownify | safeHTML }}</h4>{{- end -}}
{{- with .Get "caption" -}}<p class="figcaption__caption">{{ . | markdownify | safeHTML }}</p>{{- end -}}
</figcaption>
{{- end -}}
</figure>

View file

@ -1,13 +1,16 @@
<li class="comment">
<article class="comment__body">
<article class="comment__body" itemprop="comment" itemscope itemtype="https://schema.org/Comment">
<header class="comment__header">
<h3 class="comment__author">{{ .Params.author }}</h3>
<h3 class="comment__author" itemprop="author">{{ .Params.author }}</h3>
{{- $publishDate := time .Params.publishDate -}}
<p class="comment__publish-date">
<time class="dt-published" datetime="{{ $publishDate.Format "2006-01-02T15:04:05-07:00" }}" itemprop="datePublished">{{ $publishDate.Format "January 2" }}<sup>{{ if in (slice 1 21 31) $publishDate.Day }}st{{ else if in (slice 2 22) $publishDate.Day}}nd{{ else if in (slice 3 23) $publishDate.Day }}rd{{ else }}th{{ end }}</sup>, 1{{ $publishDate.Format "2006" | lang.NumFmt 0 }}&nbsp;<abbr style="font-variant: small-caps; font-size: 0.8em;" title="Holocene Era">HE</abbr></time>
</p>
{{- with .Params.source -}}
<p class="comment__source">Source: {{ . }}</p>
{{- end -}}
</header>
{{ .Inner | markdownify }}
<footer class="comment__footer">
{{ with .Params.source }}<p class="comment__source">Source: {{ . }}</p>{{ end }}
</footer>
{{- .Inner | markdownify -}}
</article>
</li>

View file

@ -1,94 +1,75 @@
{{- if ( and ( .Get "src" ) ( .Get "chart-id" ) ) -}}
{{- errorf "Both chart ID and resource source defined" -}}
{{- end -}}
{{ $src := $.Page.Resources.GetMatch (.Get "src") }}
{{ if ( and ( not $src ) ( not ( .Get "chart-id" ) ) ) }}
{{- $src := $.Page.Resources.GetMatch (.Get "src") -}}
{{- if ( not $src ) -}}
{{- errorf "No Page Resource found for src '%q' (%q)" ( .Get "src" ) .Page.File.Path -}}
{{ end }}
{{ $linkedResource := $.Page.Resources.GetMatch (.Get "link") }}
{{- end -}}
{{- $linkedResource := $.Page.Resources.GetMatch (.Get "link") -}}
<figure class="article__figure figure{{ with .Get "class" }} {{ . }}{{ end }}">
{{- with .Get "chart-id" -}}
<canvas class="figure__chart" id="{{ . }}">
You must enable Javascript to view this chart.
</canvas>
{{- else -}}
{{- if .Get "link" -}}
{{- if $linkedResource }}
<a href="{{ $linkedResource.RelPermalink }}"{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{ else }}
<a href="{{ .Get "link" }}">
{{ end }}
{{- end -}}
{{- if eq $src.ResourceType "image" -}}
<picture class="figure__picture"
itemprop="image">
<img class="u-photo figure__image"
{{ if ( or ( eq $src.MediaType.SubType "svg" ) ( eq $src.MediaType.SubType "gif" ) ) }}
src="{{ $src.RelPermalink }}"
{{ else }}
{{ with $src.Resize "1200x webp" }}
src="{{ .RelPermalink }}"
{{ end }}
width="{{ $src.Width }}"
height="{{ $src.Height }}"
{{ end }}
{{- with $src.Params.alt }}
alt="{{ . }}"
{{- end -}}
{{- with $src.Params.title }} title="{{ . }}" {{ end -}}
loading="lazy"
role="img"
/>
</picture>
{{- else if eq $src.ResourceType "video" -}}
{{- if eq $src.MediaType "video/ogg" -}}
<audio class="u-audio figure__audio" itemprop="audio" controls>
<source src="{{ $src.RelPermalink }}" type="{{ $src.MediaType }}" />
<p>Your browser doesn't support embedded audio, <a href="{{ $src.RelPermalink }}">view the audio here</a>.</p>
</audio>
{{- else -}}
<video class="u-video figure__video"
controls
src="{{ $src.RelPermalink }}"
poster="
{{- if $src.Params.poster -}}
{{- $posterSrc := $.Page.Resources.GetMatch ( .Get $src.Params.poster ) -}}
{{- with $posterSrc.Resize "1200x webp" -}}
{{- .RelPermalink -}}
{{- end -}}
{{- else -}}
{{- warnf "No poster defined for resource %q (%q)" $src.RelPermalink .Page.File.Path -}}
{{- end -}}
"
itemprop="video"
>
Your browser doesn't support embedded video, <a href="{{ $src.RelPermalink }}">view the video here</a>.
</video>
{{- end -}}
{{- else if ( or ( ne $src.ResourceType "image" ) ( ne $src.ResourceType "video" ) ) -}}
{{- errorf "No handling for resource of type %q" $src.ResourceType -}}
{{- end -}}
{{- if .Get "link" }}</a>{{ end -}}
<figure class="article__figure figure{{ with .Get "class" }} {{ . }}{{ end }}" role="group">
{{- if .Get "link" -}}
{{- if $linkedResource }}
<a href="{{ $linkedResource.RelPermalink }}"{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{ else }}
<a href="{{ .Get "link" }}">
{{ end }}
{{- end -}}
{{- if eq $src.ResourceType "image" -}}
<picture class="figure__picture"
itemprop="image">
<img class="u-photo figure__image"
{{ if ( or ( eq $src.MediaType.SubType "svg" ) ( eq $src.MediaType.SubType "gif" ) ) }}
src="{{ $src.RelPermalink }}"
{{ else }}
{{ with $src.Resize "1200x webp" }}
src="{{ .RelPermalink }}"
{{ end }}
width="{{ $src.Width }}"
height="{{ $src.Height }}"
{{ end }}
{{- with $src.Params.alt }}
alt="{{ . }}"
{{- end -}}
{{- with $src.Params.title }} title="{{ . }}" {{ end -}}
loading="lazy"
role="img"
/>
</picture>
{{- else if eq $src.ResourceType "video" -}}
{{- if eq $src.MediaType "video/ogg" -}}
<audio class="u-audio figure__audio" itemprop="audio" controls>
<source src="{{ $src.RelPermalink }}" type="{{ $src.MediaType }}" />
<p>Your browser doesn't support embedded audio, <a href="{{ $src.RelPermalink }}">view the audio here</a>.</p>
</audio>
{{- else -}}
<video class="u-video figure__video"
controls
src="{{ $src.RelPermalink }}"
poster="
{{- if $src.Params.poster -}}
{{- $posterSrc := $.Page.Resources.GetMatch ( .Get $src.Params.poster ) -}}
{{- with $posterSrc.Resize "1200x webp" -}}
{{- .RelPermalink -}}
{{- end -}}
{{- else -}}
{{- warnf "No poster defined for resource %q (%q)" $src.RelPermalink .Page.File.Path -}}
{{- end -}}
"
itemprop="video">
Your browser doesn't support embedded video, <a href="{{ $src.RelPermalink }}">view the video here</a>.
</video>
{{- end -}}
{{- else if ( or ( ne $src.ResourceType "image" ) ( ne $src.ResourceType "video" ) ) -}}
{{- errorf "No handling for resource of type %q" $src.ResourceType -}}
{{- end -}}
{{- if .Get "link" }}</a>{{ end -}}
{{- if or ( .Get "caption" ) ( .Get "title" ) ( $src.Params.attr ) -}}
<figcaption class="figure__caption{{ if not ( or ( .Get "caption" ) ( .Get "title" ) ) }} figure__caption--no-height{{ end }}">
{{- with $src -}}
{{ if .Params.attrlink -}}
<a class="figcaption__attrlink" href="{{ .Params.attrlink }}">
{{- end -}}
{{- if .Params.attr -}}<p class="figcaption__attr">{{ .Params.attr | safeHTML }}{{ with .Params.attrlicence }} <span class="figcaption__licence">{{ . | safeHTML }}</span>{{ end }}</p>{{- end -}}
{{- if .Params.attrlink -}}
</a>
{{- end -}}
{{- end -}}
{{- if .Params.attrlink -}}<a class="figcaption__attrlink" href="{{ .Params.attrlink }}">{{- end -}}
{{- if .Params.attr -}}<p class="figcaption__attr">{{ .Params.attr | safeHTML }}{{ with .Params.attrlicence }} <span class="figcaption__licence">{{ . | safeHTML }}</span>{{ end }}</p>{{- end -}}
{{- if .Params.attrlink -}}</a>{{- end -}}
{{- with .Get "title" -}}<h4 class="figcaption__title">{{ . | markdownify | safeHTML }}</h4>{{- end -}}
{{- with .Get "caption" -}}
<p class="figcaption__caption">{{ . | markdownify | safeHTML }}</p>
{{- end -}}
{{- with .Get "caption" -}}<p class="figcaption__caption">{{ . | markdownify | safeHTML }}</p>{{- end -}}
</figcaption>
{{- end -}}
</figure>

View file

@ -1,30 +1,81 @@
<!-- count how many times we've called this shortcode; load the css if it's the first time -->
{{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href={{ "css/hugo-easy-gallery.css" | relURL }} />{{ end }}
{{- $.Page.Scratch.Add "figurecount" 1 }}
{{ $baseURL := .Site.BaseURL }}
<div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery">
<figure class="figure--gallery gallery" itemscope itemtype="http://schema.org/ImageGallery">
{{- if or ( .Get "caption" ) ( .Get "title" ) -}}
<figcaption class="figure__caption gallery__caption{{ if not ( or ( .Get "caption" ) ( .Get "title" ) ) }} figure__caption--no-height{{ end }}">
{{- with .Get "title" -}}<h4 class="figcaption__title">{{ . | markdownify | safeHTML }}</h4>{{- end -}}
{{- with .Get "caption" -}}
<p class="figcaption__caption">{{ . | markdownify | safeHTML }}</p>
{{- end -}}
</figcaption>
{{- end -}}
{{- with (.Get "dir") -}}
<!-- If a directory was specified, generate figures for all of the images in the directory -->
{{- $files := readDir ( print "content/" $.Page.File.Dir . ) }}
{{- range $files -}}
<!-- skip files that aren't images, or that include the thumb suffix in their name -->
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp|webp|avif|jxl)" }}<!-- is the current file an image? -->
{{- if $isimg }}
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
{{- $linkURL := print $.Page.Permalink ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
<div class="box">
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<div class="img" style="background-image: url('{{ $linkURL }}');" >
<img itemprop="thumbnail" loading="lazy" src="{{ $linkURL }}" alt="{{ $caption }}" /><!-- <img> hidden if in .gallery -->
</div>
<a href="{{ $linkURL }}" itemprop="contentUrl"></a><!-- put <a> last so it is stacked on top -->
</figure>
</div>
{{- end }}
{{- $images := $.Page.Resources.Match ( print . "/*" ) }}
{{- range $images -}}
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
{{- $linkURL := print $.Page.Permalink ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
<figure class="figure gallery__figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="{{ .RelPermalink }}" itemprop="contentUrl">
<picture class="figure__picture"
itemprop="image">
<img itemprop="thumbnail"
class="u-photo gallery__thumbnail"
{{ if ( or ( eq .MediaType.SubType "svg" ) ( eq .MediaType.SubType "gif" ) ) }}
src="{{ .RelPermalink }}"
{{ else }}
{{ with .Resize "600x webp" }}
src="{{ .RelPermalink }}"
{{ end }}
width="{{ .Width }}"
height="{{ .Height }}"
{{ end }}
{{- with .Params.alt }}
alt="{{ . }}"
{{- end -}}
{{- with .Params.title }} title="{{ . }}" {{ end -}}
loading="lazy"
>
</picture>
</a>
{{- if or ( .Params.title ) ( .Params.attr ) -}}
<figcaption class="figure__caption{{ if not .Params.title }} figure__caption--no-height{{ end }}">
{{ if .Params.attrlink -}}
<a class="figcaption__attrlink" href="{{ .Params.attrlink }}"
{{- with .Params.attrtarget }} target="{{ . }}"{{ end -}}
{{- with .Params.attrrel }} rel="{{ . }}"{{ end -}}
>
{{- end -}}
{{- if .Params.attr -}}<p class="figcaption__attr">{{ .Params.attr | safeHTML }}{{ with .Params.attrlicence }} <span class="figcaption__licence">{{ . | safeHTML }}</span>{{ end }}</p>{{- end -}}
{{- if .Params.attrlink -}}
</a>
{{- end -}}
{{- if .Params.href -}}
<a href="{{- if ( eq .Params.href "asCite" ) -}}{{ .Params.cite }}{{- else -}}{{ .Params.href }}{{- end -}}">
{{- end -}}
{{- if .Params.title -}}
<h5 class="figcaption__title">
{{- if .Params.titleLang -}}
<i lang="{{ .Params.titleLang }}" title="{{ .Params.titleTr }}">
{{- end -}}
{{ .Params.title | safeHTML }}
{{- if .Params.titleLang -}}
</i>
{{- end -}}
</h5>
{{- else -}}
{{- with .Params.href -}}
<p class="figcaption__title">Link</p>
{{- end -}}
{{- end -}}
{{- if .Params.href -}}
</a>
{{- end -}}
</figcaption>
{{- end -}}
</figure>
{{- end }}
{{- else -}}
<!-- If no directory was specified, include any figure shortcodes called within the gallery -->
{{ .Inner }}
{{- end }}
</div>
</figure>

View file

@ -1,4 +1,8 @@
{{- $resource := .Page.Resources.GetMatch ($.Get 0) -}}
{{- with $resource -}}
{{- $resource.RelPermalink -}}
{{- $src := $.Page.Resources.GetMatch ($.Get 0) -}}
{{- if ( not $src ) -}}
{{- errorf "No Page Resource found for src '%q' (%q)" ( $.Get 0 ) .Page.File.Path -}}
{{- end -}}
{{- with $src -}}
{{- .RelPermalink -}}
{{- end -}}