refactor templates layout
@see https://gohugo.io/templates/new-templatesystem-overview/
This commit is contained in:
parent
a83f339dc8
commit
230c46411b
102 changed files with 2 additions and 2 deletions
25
layouts/_partials/single/main-header/authors.html
Normal file
25
layouts/_partials/single/main-header/authors.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{- /*
|
||||
Renders the authors for an item.
|
||||
|
||||
@params authors The item's author(s).
|
||||
@params sc The site context.
|
||||
*/ -}}
|
||||
|
||||
<span style="display: none">
|
||||
<p>Author{{ with .authors }}s{{ end }}:
|
||||
{{- with .authors -}}
|
||||
</p>
|
||||
<ul>
|
||||
{{- range . -}}
|
||||
{{- if ( eq . $.site_author.name ) -}}
|
||||
<li><p><a class="p-author" itemprop="author" rel="author" href="{{ $.sc.Site.Home.Permalink }}">{{ $.sc.Site.Params.Author.name }}</a></p></li>
|
||||
{{- else -}}
|
||||
<li><p class="p-author" itemprop="author">{{- . -}}</p></li>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</ul>
|
||||
{{- else -}}
|
||||
<a class="p-author" itemprop="author" rel="author" href="{{ $.sc.Site.Home.Permalink }}">{{ $.sc.Site.Params.Author.name }}</a>
|
||||
</p>
|
||||
{{- end -}}
|
||||
</span>
|
58
layouts/_partials/single/main-header/dates.html
Normal file
58
layouts/_partials/single/main-header/dates.html
Normal file
|
@ -0,0 +1,58 @@
|
|||
{{- /*
|
||||
Displays dates for an item.
|
||||
|
||||
@params publishDate The date an item was published.
|
||||
@params lastmodDate The date an item was last modified.
|
||||
*/
|
||||
-}}
|
||||
|
||||
{{ $publishDate := .publishDate }}
|
||||
{{ $lastmodDate := .lastmodDate }}
|
||||
|
||||
|
||||
<p class="article-header__publish-date">
|
||||
Published:
|
||||
<time
|
||||
class="dt-published"
|
||||
datetime="{{ $publishDate | time.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.FormatNumberCustom 0 }} <abbr
|
||||
style="font-variant: small-caps; font-size: 0.8em;"
|
||||
title="Holocene Era"
|
||||
>HE</abbr
|
||||
></time
|
||||
>
|
||||
</p>
|
||||
|
||||
<p class="article-header__modified-date">
|
||||
Last modified:
|
||||
<time
|
||||
class="dt-updated"
|
||||
datetime="{{ $lastmodDate | time.Format "2006-01-02T15:04:05-07:00" }}"
|
||||
itemprop="dateModified"
|
||||
>{{- $lastmodDate.Format "January 2" -}}<sup>{{- if in (slice 1 21 31) $lastmodDate.Day -}}
|
||||
st
|
||||
{{- else if in (slice 2 22) $lastmodDate.Day -}}
|
||||
nd
|
||||
{{- else if in (slice 3 23) $lastmodDate.Day -}}
|
||||
rd
|
||||
{{- else -}}
|
||||
th
|
||||
{{- end -}}</sup>,
|
||||
1{{- $lastmodDate.Format "2006" | lang.FormatNumberCustom 0 }} <abbr
|
||||
style="font-variant: small-caps; font-size: 0.8em;"
|
||||
title="Holocene Era"
|
||||
>HE</abbr
|
||||
></time
|
||||
>
|
||||
</p>
|
67
layouts/_partials/single/main-header/item-tile.html
Normal file
67
layouts/_partials/single/main-header/item-tile.html
Normal file
|
@ -0,0 +1,67 @@
|
|||
{{- /*
|
||||
Renders the header tile for an item.
|
||||
|
||||
@params pc The page context.
|
||||
@params sc The site context.
|
||||
*/
|
||||
-}}
|
||||
|
||||
{{- if ( not ( isset . "sc" ) ) -}}
|
||||
{{- errorf "No site context received" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if ( not ( isset . "pc" ) ) -}}
|
||||
{{- errorf "No page context received (%q)" .sc.Page.File.Dir -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ with .pc.Params.featured_image }}
|
||||
<img
|
||||
class="u-photo"
|
||||
style="display: none;"
|
||||
src="
|
||||
{{- with ( $.pc.Resources.GetMatch . ) -}}
|
||||
{{- partialCached "images/get-image.html" ( dict "img" . ) .Title -}}
|
||||
{{- else -}}
|
||||
{{- . -}}
|
||||
{{- end -}}
|
||||
"
|
||||
itemprop="image"
|
||||
{{- with ( $.pc.Resources.GetMatch . ) -}}
|
||||
alt="{{ .Params.alt }}"
|
||||
{{- end -}}
|
||||
/>
|
||||
{{ end }}
|
||||
|
||||
|
||||
<div
|
||||
class="article-header__featured-image"
|
||||
{{ with .pc.Params.featured_image }}
|
||||
{{ with ( $.pc.Resources.GetMatch . ) }}
|
||||
style="background-image: url({{- partialCached "images/get-image.html" ( dict "img" . ) .Title -}})"
|
||||
{{ else }}
|
||||
{{- if $.pc.Page.Resources -}}
|
||||
{{- 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 -}}
|
||||
{{- else -}}
|
||||
{{- warnf "No Page Resource found for src '%q' (%q)." . $.pc.Page.File.Path -}}
|
||||
{{- end -}}
|
||||
style="background-image: url({{ . }})"
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
>
|
||||
<div class="article-header__title-wrapper">
|
||||
<a
|
||||
class="u-url u-uid"
|
||||
style="display: none"
|
||||
href="{{ .pc.Permalink }}"
|
||||
></a>
|
||||
{{- with .pc.File -}}
|
||||
{{- partial "text/item-title.html" ( dict "pc" $.pc "sc" $.sc "class" "article-header" ) -}}
|
||||
{{- else -}}
|
||||
{{- partial "text/item-title.html" ( dict "pc" $.pc "sc" $.sc "class" "article-header" ) -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
{{ with ( .pc.Resources.GetMatch .pc.Params.featured_image ) }}
|
||||
{{- partial "media/attr.html" ( dict "pc" $.pc "sc" $.sc "params" .Params ) -}}
|
||||
{{ end }}
|
||||
</div>
|
16
layouts/_partials/single/main-header/notes.html
Normal file
16
layouts/_partials/single/main-header/notes.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{{- /*
|
||||
Renders the notes for an item.
|
||||
|
||||
@params note The notes for an item.
|
||||
@params sc Site context.
|
||||
*/
|
||||
-}}
|
||||
|
||||
|
||||
<aside class="article-header__notes">
|
||||
<ul>
|
||||
{{ range .notes }}
|
||||
<li>{{ . | $.sc.RenderString | safeHTML }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</aside>
|
18
layouts/_partials/single/main-header/series.html
Normal file
18
layouts/_partials/single/main-header/series.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{{- /*
|
||||
Renders the series of an item.
|
||||
|
||||
@params series A list of series' for the item.
|
||||
*/
|
||||
-}}
|
||||
|
||||
|
||||
<p class="article-header__series">
|
||||
Part of series:
|
||||
{{ range .series }}
|
||||
<a
|
||||
class="u-url"
|
||||
href="{{ .RelPermalink }}"
|
||||
>{{ .LinkTitle }}</a
|
||||
>
|
||||
{{ end }}
|
||||
</p>
|
34
layouts/_partials/single/main-header/toc.html
Normal file
34
layouts/_partials/single/main-header/toc.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
{{- /*
|
||||
Renders appendices and corrigenda for an item.
|
||||
|
||||
@params toc The page ToC.
|
||||
@params appendices The item's appendices. Optional.
|
||||
@params fileDir The file folder name.
|
||||
*/
|
||||
-}}
|
||||
|
||||
{{ $empty_toc_html := "<nav id=\"TableOfContents\"></nav>" }}
|
||||
|
||||
{{ if and ( .toc ) ( ne .toc $empty_toc_html ) }}
|
||||
<nav class="article-header__table-of-contents">
|
||||
<h3 class="article-header__subtitle">Table of Contents</h3>
|
||||
{{ .toc }}
|
||||
{{- if fileExists ( path.Join .fileDir "appendices.md" ) -}}
|
||||
<ul class="toc-list--appendices">
|
||||
<li>
|
||||
<a href="#appendices">Appendices</a>
|
||||
<ol>
|
||||
{{ range .appendices }}
|
||||
<li><a href="#{{ . | anchorize }}">{{ . | safeHTML }}</a></li>
|
||||
{{ end }}
|
||||
</ol>
|
||||
</li>
|
||||
</ul>
|
||||
{{- end -}}
|
||||
{{- if fileExists ( path.Join .fileDir "corrigenda.md" ) -}}
|
||||
<ul class="toc-list--corrigenda">
|
||||
<li><a href="#corrigenda">Corrigenda</a></li>
|
||||
</ul>
|
||||
{{- end -}}
|
||||
</nav>
|
||||
{{ end }}
|
33
layouts/_partials/single/main-header/warnings.html
Normal file
33
layouts/_partials/single/main-header/warnings.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
{{- /*
|
||||
Renders the automatic warnings for an item.
|
||||
|
||||
@params pc The page context.
|
||||
*/
|
||||
-}}
|
||||
|
||||
{{ $post_age_in_years := math.Round ( div ( div ( now.Sub .pc.PublishDate ).Hours 24 ) 365 ) }}
|
||||
|
||||
{{ if ( or .pc.Params.site .pc.Params.controversial ( gt $post_age_in_years 2 ) ) }}
|
||||
<aside class="article-header__warnings">
|
||||
<ul>
|
||||
{{ if ( gt $post_age_in_years 2 ) }}
|
||||
<li>
|
||||
This piece was written <strong>over {{ $post_age_in_years }} years ago</strong>. It may no longer accurately reflect my views now,
|
||||
or may be factually outdated.
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .pc.Params.controversial }}
|
||||
<li>
|
||||
This piece has been marked as potentially <strong>controversial</strong>, whether due to the topic addressed, the content of the
|
||||
article, or both. Don't say you weren't warned.
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .pc.Params.site }}
|
||||
<li>
|
||||
This piece was originally written for an older version of this site. As such, it may not have transferred over properly and some
|
||||
images and links might be broken.
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</aside>
|
||||
{{ end }}
|
9
layouts/_partials/single/main-header/word-count.html
Normal file
9
layouts/_partials/single/main-header/word-count.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{- /*
|
||||
Displays the length of an item.
|
||||
|
||||
@params wordCount The wordcount of an item.
|
||||
*/
|
||||
-}}
|
||||
|
||||
|
||||
<p class="article-header__word-count">~<span itemprop="wordCount">{{ .wordCount | lang.FormatNumberCustom 0 }}</span> words</p>
|
Loading…
Add table
Add a link
Reference in a new issue