Fix sorting

This commit is contained in:
Ben Goldsworthy 2023-02-28 17:03:09 -05:00
parent f5914ab8c5
commit 1d98bd9a56

View file

@ -1,33 +1,84 @@
{{ if ( eq ( .Scratch.Get "listMode" ) "log" ) }} {{ if ( eq ( .Scratch.Get "listMode" ) "log" ) }}
{{ .Scratch.Set "filterCol" "Date Watched" }} <tr>
{{ .Scratch.Set "filterDir" "desc" }} <td colspan=4><h3>Diary</h3></td>
{{ else }} </tr>
{{ .Scratch.Set "filterCol" "Title" }} {{ range ( sort ( where $.Site.Data.films.log "Date Watched" "!=" "" ) "Date Watched" "desc" ) }}
{{ .Scratch.Set "filterDir" "asc" }} <tr>
{{ end }} <td>{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}</td>
<td>
{{ range ( sort ( sort ( index $.Site.Data.films ( .Scratch.Get "listMode" ) ) "Title" "asc" ) ( .Scratch.Get "filterCol" ) ( .Scratch.Get "filterDir" ) ) }} {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}}
<tr> {{ range . }}
<td>{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}</td> <a href="{{ .RelPermalink }}">
<td> {{ end }}
{{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} {{- end -}}
{{ range . }} <cite class="film">{{ .Title }}</cite>
<a href="{{ .RelPermalink }}"> {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}}
{{ end }} </a>
{{- end -}}
</td>
<td>{{ index . "Release Year" }}</td>
<td>
{{- if ( index . "Date Watched" ) -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}}
{{- if .Rewatch }} &#x21BB;{{ end -}}
{{- else -}}
n/a
{{- end -}} {{- end -}}
<cite class="film">{{ .Title }}</cite> </td>
{{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}} </tr>
</a> {{ end }}
<tr>
<td colspan=4><h3>Assorted</h3></td>
</tr>
{{ range ( sort ( where $.Site.Data.films.log "Date Watched" "" ) "Title" "asc" ) }}
<tr>
<td>{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}</td>
<td>
{{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}}
{{ range . }}
<a href="{{ .RelPermalink }}">
{{ end }}
{{- end -}}
<cite class="film">{{ .Title }}</cite>
{{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}}
</a>
{{- end -}}
</td>
<td>{{ index . "Release Year" }}</td>
<td>
{{- if ( index . "Date Watched" ) -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}}
{{- if .Rewatch }} &#x21BB;{{ end -}}
{{- else -}}
n/a
{{- end -}} {{- end -}}
</td> </td>
<td>{{ index . "Release Year" }}</td> </tr>
<td> {{ end }}
{{- if ( index . "Date Watched" ) -}} {{ else if ( eq ( .Scratch.Get "listMode" ) "wishlist" ) }}
{{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}} {{ range ( sort $.Site.Data.films.wishlist "Title" "asc" ) }}
{{- if .Rewatch }} &#x21BB;{{ end -}} <tr>
{{- else -}} <td>{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}</td>
n/a <td>
{{- end -}} {{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}}
</td> {{ range . }}
</tr> <a href="{{ .RelPermalink }}">
{{ end }}
{{- end -}}
<cite class="film">{{ .Title }}</cite>
{{- with ( where ( where $.Site.Pages "Section" "films" ) "Title" .Title ) -}}
</a>
{{- end -}}
</td>
<td>{{ index . "Release Year" }}</td>
<td>
{{- if ( index . "Date Watched" ) -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Watched" ) -}}
{{- if .Rewatch }} &#x21BB;{{ end -}}
{{- else -}}
n/a
{{- end -}}
</td>
</tr>
{{ end }}
{{ end }} {{ end }}