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,19 +18,37 @@
|
|||||||
<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 }}
|
{{ if .Params.hidden }}
|
||||||
{{ continue }}
|
{{ continue }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if and (.Params.release) (ge (time.AsTime .Params.release) (time now)) }}
|
{{ if false }} and (.Params.release) (ge (time.AsTime .Params.release) (time now))
|
||||||
{{ continue }}
|
{{ continue }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
@@ -72,11 +97,10 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</span>
|
</span>
|
||||||
<span class="post-day">
|
<span class="post-day">
|
||||||
<!-- TBD: Show the Release attribute if later than Date. -->
|
|
||||||
{{ if .Site.Params.dateformShort }}
|
{{ if .Site.Params.dateformShort }}
|
||||||
{{ time.Format .Site.Params.dateformShort .Date }}
|
{{ time.Format .Site.Params.dateformShort $date }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ time.Format "Jan 2" .Date }}
|
{{ time.Format "Jan 2" $date }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -84,7 +108,6 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
|
||||||
{{ partial "pagination-list.html" . }}
|
{{ partial "pagination-list.html" . }}
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user