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" }}
|
{{ 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">
|
<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 }}
|
{{ range $paginator.Pages }}
|
||||||
<div class="post on-list">
|
<div class="post on-list">
|
||||||
<h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
<h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||||
@ -17,12 +17,9 @@
|
|||||||
<span class="post-date">
|
<span class="post-date">
|
||||||
{{ .Date.Format ($.Site.Params.DateFormatList | default "2006-01-02") }}
|
{{ .Date.Format ($.Site.Params.DateFormatList | default "2006-01-02") }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{{ if $.Site.Params.LastModDisplay}}
|
{{ if $.Site.Params.LastModDisplay}}
|
||||||
{{ with .Lastmod }}
|
{{ partial "lastmod.html" . }}
|
||||||
<span class="post-moddate">
|
|
||||||
{{ $.Site.Params.LastModDisplay }} {{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
|
||||||
</span>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ with .Params.Author }}<span class="post-author">— {{ $.Site.Params.WrittenBy | default "Written by" }} {{ . }}</span>{{ end }}
|
{{ with .Params.Author }}<span class="post-author">— {{ $.Site.Params.WrittenBy | default "Written by" }} {{ . }}</span>{{ end }}
|
||||||
@ -31,7 +28,6 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{{ if .Params.tags }}
|
{{ if .Params.tags }}
|
||||||
<span class="post-tags">
|
<span class="post-tags">
|
||||||
{{ range .Params.tags }}
|
{{ range .Params.tags }}
|
||||||
@ -62,4 +58,4 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ partial "pagination.html" . }}
|
{{ partial "pagination.html" . }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
@ -1,19 +1,18 @@
|
|||||||
{{ define "main" }}
|
{{ 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">
|
<div class="post">
|
||||||
<h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>
|
<h2 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>
|
||||||
<div class="post-meta">
|
<div class="post-meta">
|
||||||
{{ with .Date | default nil }}
|
{{ if .Date | default nil }}
|
||||||
<span class="post-date">
|
<span class="post-date">
|
||||||
{{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
{{ .Date.Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
||||||
</span>
|
</span>
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if $.Site.Params.LastModDisplay}}
|
{{ if eq .Type $contentTypeName }}
|
||||||
{{ if .Date }}
|
{{ if $.Site.Params.LastModDisplay}}
|
||||||
{{ with .Lastmod }}
|
{{ partial "lastmod.html" . }}
|
||||||
<span class="post-moddate">
|
|
||||||
{{ $.Site.Params.LastModDisplay }} {{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}
|
|
||||||
</span>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@ -72,4 +71,4 @@
|
|||||||
|
|
||||||
{{ partial "comments.html" . }}
|
{{ partial "comments.html" . }}
|
||||||
</div>
|
</div>
|
||||||
{{ 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