mirror of
https://github.com/thomasjsn/hugo-theme-hello-friend.git
synced 2024-11-21 23:35:08 +01:00
Integrating panr's changes to use partial for lastmod date display, also checks if lastmoddate > date
This commit is contained in:
commit
3b9ad17e22
@ -1,14 +1,14 @@
|
||||
{{ define "main" }}
|
||||
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
|
||||
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
|
||||
|
||||
{{ $PageContext := . }}
|
||||
{{ if .IsHome }}
|
||||
{{ $PageContext = .Site }}
|
||||
{{ end }}
|
||||
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
|
||||
|
||||
<div class="posts">
|
||||
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
|
||||
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
|
||||
|
||||
{{ $PageContext := . }}
|
||||
{{ if .IsHome }}
|
||||
{{ $PageContext = .Site }}
|
||||
{{ end }}
|
||||
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
|
||||
|
||||
{{ range $paginator.Pages }}
|
||||
<div class="post on-list">
|
||||
<h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||
@ -17,12 +17,9 @@
|
||||
<span class="post-date">
|
||||
{{ .Date.Format ($.Site.Params.DateFormatList | default "2006-01-02") }}
|
||||
</span>
|
||||
|
||||
{{ if $.Site.Params.LastModDisplay}}
|
||||
{{ with .Lastmod }}
|
||||
<span class="post-moddate">
|
||||
{{ $.Site.Params.LastModDisplay }} {{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
||||
</span>
|
||||
{{ end }}
|
||||
{{ partial "lastmod.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Params.Author }}<span class="post-author">— {{ $.Site.Params.WrittenBy | default "Written by" }} {{ . }}</span>{{ end }}
|
||||
@ -31,7 +28,6 @@
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
|
||||
{{ if .Params.tags }}
|
||||
<span class="post-tags">
|
||||
{{ range .Params.tags }}
|
||||
|
@ -1,19 +1,18 @@
|
||||
{{ define "main" }}
|
||||
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
|
||||
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
|
||||
|
||||
<div class="post">
|
||||
<h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>
|
||||
<div class="post-meta">
|
||||
{{ with .Date | default nil }}
|
||||
{{ if .Date | default nil }}
|
||||
<span class="post-date">
|
||||
{{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
||||
{{ .Date.Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
{{ if $.Site.Params.LastModDisplay}}
|
||||
{{ if .Date }}
|
||||
{{ with .Lastmod }}
|
||||
<span class="post-moddate">
|
||||
{{ $.Site.Params.LastModDisplay }} {{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
||||
</span>
|
||||
{{ if eq .Type $contentTypeName }}
|
||||
{{ if $.Site.Params.LastModDisplay}}
|
||||
{{ partial "lastmod.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
7
layouts/partials/lastmod.html
Normal file
7
layouts/partials/lastmod.html
Normal file
@ -0,0 +1,7 @@
|
||||
{{ if gt .Lastmod .Date }}
|
||||
{{ with .Lastmod }}
|
||||
<span class="post-moddate">
|
||||
({{ $.Site.Params.LastModDisplay }} {{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }})
|
||||
</span>
|
||||
{{ end }}
|
||||
{{ end }}
|
Loading…
Reference in New Issue
Block a user