From 1d98bd9a56795c21cc40d956efee73c5ce356d43 Mon Sep 17 00:00:00 2001 From: Ben Goldsworthy Date: Tue, 28 Feb 2023 17:03:09 -0500 Subject: [PATCH] Fix sorting --- layouts/partials/films/table-body.html | 109 ++++++++++++++++++------- 1 file changed, 80 insertions(+), 29 deletions(-) diff --git a/layouts/partials/films/table-body.html b/layouts/partials/films/table-body.html index 3e62e6c..b53f9f8 100644 --- a/layouts/partials/films/table-body.html +++ b/layouts/partials/films/table-body.html @@ -1,33 +1,84 @@ {{ if ( eq ( .Scratch.Get "listMode" ) "log" ) }} - {{ .Scratch.Set "filterCol" "Date Watched" }} - {{ .Scratch.Set "filterDir" "desc" }} -{{ else }} - {{ .Scratch.Set "filterCol" "Title" }} - {{ .Scratch.Set "filterDir" "asc" }} -{{ end }} - -{{ range ( sort ( sort ( index $.Site.Data.films ( .Scratch.Get "listMode" ) ) "Title" "asc" ) ( .Scratch.Get "filterCol" ) ( .Scratch.Get "filterDir" ) ) }} - - {{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }} - - {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} - {{ range . }} - - {{ end }} + +

Diary

+ + {{ range ( sort ( where $.Site.Data.films.log "Date Watched" "!=" "" ) "Date Watched" "desc" ) }} + + {{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }} + + {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} + {{ range . }} +
+ {{ end }} + {{- end -}} + {{ .Title }} + {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} + + {{- end -}} + + {{ index . "Release Year" }} + + {{- if ( index . "Date Watched" ) -}} + {{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}} + {{- if .Rewatch }} ↻{{ end -}} + {{- else -}} + n/a {{- end -}} - {{ .Title }} - {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} - + + + {{ end }} + +

Assorted

+ + {{ range ( sort ( where $.Site.Data.films.log "Date Watched" "" ) "Title" "asc" ) }} + + {{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }} + + {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} + {{ range . }} + + {{ end }} + {{- end -}} + {{ .Title }} + {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} + + {{- end -}} + + {{ index . "Release Year" }} + + {{- if ( index . "Date Watched" ) -}} + {{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}} + {{- if .Rewatch }} ↻{{ end -}} + {{- else -}} + n/a {{- end -}} - - {{ index . "Release Year" }} - - {{- if ( index . "Date Watched" ) -}} - {{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}} - {{- if .Rewatch }} ↻{{ end -}} - {{- else -}} - n/a - {{- end -}} - - + + + {{ end }} +{{ else if ( eq ( .Scratch.Get "listMode" ) "wishlist" ) }} + {{ range ( sort $.Site.Data.films.wishlist "Title" "asc" ) }} + + {{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }} + + {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} + {{ range . }} + + {{ end }} + {{- end -}} + {{ .Title }} + {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} + + {{- end -}} + + {{ index . "Release Year" }} + + {{- if ( index . "Date Watched" ) -}} + {{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}} + {{- if .Rewatch }} ↻{{ end -}} + {{- else -}} + n/a + {{- end -}} + + + {{ end }} {{ end }}