Add lastmod, Git commit info to pages

This commit is contained in:
Will Faught
2023-02-09 22:50:18 -08:00
parent eb4e74fb0c
commit ff9fc5595a
3 changed files with 44 additions and 2 deletions

View File

@@ -20,6 +20,14 @@
{{ $titlelink := $page.Params.link }}
{{ $titlepage := $page.RelPermalink }}
{{ $commiturl := "" }}
{{ $lastmod := cond (eq $date $page.Lastmod) "" $page.Lastmod }}
{{ $lastmodshow := and $lastmod ($page.Param "paige.main.metadata.date.lastmod.hide" | not) }}
{{ if and ($page.Param "paige.main.metadata.git.commit_url_prefix") $page.GitInfo }}
{{ $commiturl = print ($page.Param "paige.main.metadata.git.commit_url_prefix") $page.GitInfo.Hash }}
{{ end }}
<section {{ with $sectionclass }} class="{{ . }}" {{ end }}>
{{ with $title }}
<h1 {{ with $titleclass }} class="{{ . }}" {{ end }}>{{ with $titlelink }}<a href="{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end }}{{ if $page.Scratch.Get "paige_list_show_content" }}<a aria-label="{{ i18n `paige_aria_page_link` }}" class="paige-header-link" href="{{ $titlepage }}">#</a>{{ end }}</h1>
@@ -53,7 +61,17 @@
{{ with $date }}
<p {{ if or $dateclass $readingtime }} class="{{ if $readingtime }} {{ $nogap }} {{ end }} {{ with $dateclass }} {{ . }} {{ end }}" {{ end }}>
<time datetime="{{ .Format `2006-01-02` }}">{{ time.Format $dateformat . }}</time>
{{ if $lastmodshow }}
<time datetime="{{ .Format `2006-01-02` }}">{{ time.Format $dateformat . }}</time> &middot; {{ with $commiturl }} <a class="link-secondary text-decoration-none" href="{{ . }}"> {{ end }} <time datetime="{{ .Format `2006-01-02` }}">{{ time.Format $dateformat $lastmod }}</time> {{ if $commiturl }} </a> {{ end }}
{{ else }}
{{ with $commiturl }}
<a class="link-secondary text-decoration-none" href="{{ . }}">
{{ end }}
<time datetime="{{ .Format `2006-01-02` }}">{{ time.Format $dateformat . }}</time>
{{ if $commiturl }}
</a>
{{ end }}
{{ end }}
</p>
{{ end }}