Sorting between articles with Release set is working, but still not being compared against .Date.
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
{{ $paginator := .Paginate .Data.Pages }}
|
|
||||||
|
{{ $oldYear := "" }}
|
||||||
|
|
||||||
|
{{ $sortedPages := sort .Data.Pages "Params.release" "desc" }}
|
||||||
|
{{ $paginator := .Paginate $sortedPages }}
|
||||||
|
|
||||||
|
{{- /* $sortedPages := .Data.Pages.ByParam "release" */ -}}
|
||||||
|
{{- /* $paginator := .Paginate $sortedPages */ -}}
|
||||||
|
|
||||||
<main class="posts">
|
<main class="posts">
|
||||||
<h1>{{ .Title }}</h1>
|
<h1>{{ .Title }}</h1>
|
||||||
@@ -11,80 +18,96 @@
|
|||||||
<div class="content">{{ .Content }}</div>
|
<div class="content">{{ .Content }}</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ range $paginator.Pages.GroupByDate "2006" }}
|
{{ range $paginator.Pages }}
|
||||||
|
|
||||||
|
{{/* Show the Release attribute if later than Date. */}}
|
||||||
|
|
||||||
|
{{ $date := .Date }}
|
||||||
|
{{ if and (.Params.release) (ge (time.AsTime .Params.release) (time.AsTime .Date)) }}
|
||||||
|
{{ $date = .Params.release }}
|
||||||
|
{{ end }}
|
||||||
|
{{ $date = time.AsTime $date }}
|
||||||
|
|
||||||
|
{{/* Custom year grouping in order to keep paginator order. */}}
|
||||||
|
|
||||||
|
{{ $year := $date.Year }}
|
||||||
|
{{ if not (eq $oldYear $year) }}
|
||||||
|
{{ if not (eq $oldYear "") }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
<div class="posts-group">
|
<div class="posts-group">
|
||||||
<div class="post-year">{{ .Key }}</div>
|
<div class="post-year">{{ time.Format "2006" $date }}</div>
|
||||||
|
{{ end }}
|
||||||
|
{{ $oldYear = $year }}
|
||||||
|
|
||||||
<ul class="posts-list">
|
<ul class="posts-list">
|
||||||
{{ range .Pages }}
|
|
||||||
|
|
||||||
<!-- TBD: If marked Hidden or Release date is in the future, skip. -->
|
{{/* If marked Hidden or Release date is in the future, skip. */}}
|
||||||
{{ if .Params.hidden }}
|
|
||||||
{{ continue }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if and (.Params.release) (ge (time.AsTime .Params.release) (time now)) }}
|
{{ if .Params.hidden }}
|
||||||
{{ continue }}
|
{{ continue }}
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<li class="post-item">
|
|
||||||
<a href="{{.Permalink}}" class="post-item-inner">
|
|
||||||
<span class="post-title">
|
|
||||||
{{ if .Params.draft }}
|
|
||||||
{{ print "(DRAFT) "}}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if .Params.pinned }}
|
|
||||||
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
|
||||||
src="/feathericons/16px-a9a9b3/paperclip.svg" alt="Pinned:"
|
|
||||||
>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if .Params.video }}
|
|
||||||
Video:
|
|
||||||
{{ else if .Params.audio }}
|
|
||||||
Audio:
|
|
||||||
{{ else if .Params.tags }}
|
|
||||||
{{ $prefix := (index .Params.tags 0 | title) }}
|
|
||||||
{{ if eq $prefix "Ebook" }}
|
|
||||||
eBook:
|
|
||||||
{{ else }}
|
|
||||||
{{ $prefix }}:
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ .Title }}{{ if and (.Params.subtitle) (and (.Params.author) (.Params.date)) }}
|
|
||||||
{{ "--" | markdownify }} {{ .Params.subtitle}}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if .Params.feathericon }}
|
|
||||||
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
|
||||||
src="/feathericons/16px-a9a9b3/{{ print .Params.feathericon }}.svg" alt=""
|
|
||||||
>
|
|
||||||
{{ else if .Params.video }}
|
|
||||||
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
|
||||||
src="/feathericons/16px-a9a9b3/film.svg" alt="(VIDEO)"
|
|
||||||
>
|
|
||||||
{{ else if .Params.audio }}
|
|
||||||
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
|
||||||
src="/feathericons/16px-a9a9b3/music.svg" alt="(AUDIO)"
|
|
||||||
>
|
|
||||||
{{ end }}
|
|
||||||
</span>
|
|
||||||
<span class="post-day">
|
|
||||||
<!-- TBD: Show the Release attribute if later than Date. -->
|
|
||||||
{{ if .Site.Params.dateformShort }}
|
|
||||||
{{ time.Format .Site.Params.dateformShort .Date }}
|
|
||||||
{{ else }}
|
|
||||||
{{ time.Format "Jan 2" .Date }}
|
|
||||||
{{ end }}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
|
||||||
</div>
|
{{ if false }} and (.Params.release) (ge (time.AsTime .Params.release) (time now))
|
||||||
{{ end }}
|
{{ continue }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<li class="post-item">
|
||||||
|
<a href="{{.Permalink}}" class="post-item-inner">
|
||||||
|
<span class="post-title">
|
||||||
|
{{ if .Params.draft }}
|
||||||
|
{{ print "(DRAFT) "}}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if .Params.pinned }}
|
||||||
|
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
||||||
|
src="/feathericons/16px-a9a9b3/paperclip.svg" alt="Pinned:"
|
||||||
|
>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if .Params.video }}
|
||||||
|
Video:
|
||||||
|
{{ else if .Params.audio }}
|
||||||
|
Audio:
|
||||||
|
{{ else if .Params.tags }}
|
||||||
|
{{ $prefix := (index .Params.tags 0 | title) }}
|
||||||
|
{{ if eq $prefix "Ebook" }}
|
||||||
|
eBook:
|
||||||
|
{{ else }}
|
||||||
|
{{ $prefix }}:
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ .Title }}{{ if and (.Params.subtitle) (and (.Params.author) (.Params.date)) }}
|
||||||
|
{{ "--" | markdownify }} {{ .Params.subtitle}}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if .Params.feathericon }}
|
||||||
|
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
||||||
|
src="/feathericons/16px-a9a9b3/{{ print .Params.feathericon }}.svg" alt=""
|
||||||
|
>
|
||||||
|
{{ else if .Params.video }}
|
||||||
|
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
||||||
|
src="/feathericons/16px-a9a9b3/film.svg" alt="(VIDEO)"
|
||||||
|
>
|
||||||
|
{{ else if .Params.audio }}
|
||||||
|
<img style="display: inline-block; vertical-align: middle; margin-right: 4px;"
|
||||||
|
src="/feathericons/16px-a9a9b3/music.svg" alt="(AUDIO)"
|
||||||
|
>
|
||||||
|
{{ end }}
|
||||||
|
</span>
|
||||||
|
<span class="post-day">
|
||||||
|
{{ if .Site.Params.dateformShort }}
|
||||||
|
{{ time.Format .Site.Params.dateformShort $date }}
|
||||||
|
{{ else }}
|
||||||
|
{{ time.Format "Jan 2" $date }}
|
||||||
|
{{ end }}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
{{ partial "pagination-list.html" . }}
|
{{ partial "pagination-list.html" . }}
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user