From a74da74d43abc06c39adf1934d76845280d14a11 Mon Sep 17 00:00:00 2001 From: Ben Goldsworthy Date: Fri, 21 Feb 2025 18:44:27 +0100 Subject: [PATCH] fix: render games --- layouts/partials/cite.html | 4 +- layouts/partials/games/rows/date_added.html | 7 ++ layouts/partials/games/rows/platforms.html | 1 + layouts/partials/games/rows/release-date.html | 7 ++ layouts/partials/games/rows/title.html | 1 + layouts/partials/games/table-body.html | 68 +++++++++++-------- 6 files changed, 56 insertions(+), 32 deletions(-) create mode 100644 layouts/partials/games/rows/date_added.html create mode 100644 layouts/partials/games/rows/platforms.html create mode 100644 layouts/partials/games/rows/release-date.html create mode 100644 layouts/partials/games/rows/title.html diff --git a/layouts/partials/cite.html b/layouts/partials/cite.html index f511f42..2d15d06 100644 --- a/layouts/partials/cite.html +++ b/layouts/partials/cite.html @@ -9,11 +9,11 @@ itemscope itemprop="citation" itemtype="https://schema.org/{{- $itemType -}}" - {{- if $.titleTrans -}} + {{- if .titleTrans -}} lang="{{- $.titleLang -}}" title="{{- $.titleTrans -}}" {{- end -}}> - {{- default .Title $.title -}} + {{- .title -}} {{- with $pages -}}{{- end -}} diff --git a/layouts/partials/games/rows/date_added.html b/layouts/partials/games/rows/date_added.html new file mode 100644 index 0000000..7f4381d --- /dev/null +++ b/layouts/partials/games/rows/date_added.html @@ -0,0 +1,7 @@ +{{- with . -}} + {{ with try ( time.Format "Jan 2, 2006" . ) }} + {{ .Value }} + {{ else }} + {{ . }} + {{ end }} +{{- end -}} diff --git a/layouts/partials/games/rows/platforms.html b/layouts/partials/games/rows/platforms.html new file mode 100644 index 0000000..55a25b3 --- /dev/null +++ b/layouts/partials/games/rows/platforms.html @@ -0,0 +1 @@ +{{ . }} diff --git a/layouts/partials/games/rows/release-date.html b/layouts/partials/games/rows/release-date.html new file mode 100644 index 0000000..7f4381d --- /dev/null +++ b/layouts/partials/games/rows/release-date.html @@ -0,0 +1,7 @@ +{{- with . -}} + {{ with try ( time.Format "Jan 2, 2006" . ) }} + {{ .Value }} + {{ else }} + {{ . }} + {{ end }} +{{- end -}} diff --git a/layouts/partials/games/rows/title.html b/layouts/partials/games/rows/title.html new file mode 100644 index 0000000..c962ebb --- /dev/null +++ b/layouts/partials/games/rows/title.html @@ -0,0 +1 @@ +{{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" "title" .title "titleLang" .original_language "titleTrans" .original_title ) -}} diff --git a/layouts/partials/games/table-body.html b/layouts/partials/games/table-body.html index 43406fb..0a15ed8 100644 --- a/layouts/partials/games/table-body.html +++ b/layouts/partials/games/table-body.html @@ -1,16 +1,18 @@ {{ if ( eq ( .Scratch.Get "listMode" ) "current" ) }} {{ range ( sort $.Site.Data.games.current "Date Started" "desc" ) }} - TODO + {{ partial "games/rows/date_added.html" .date_added -}} - {{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" ) -}} + {{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" "title" .title "titleLang" .original_language "titleTrans" .original_title ) -}} - {{ .Platforms }} - {{ index . "Date Released" }} + {{- partial "games/rows/platforms.html" .platform -}} - {{- if index . "Date Started" -}} + {{- partial "games/rows/release-date.html" .release_date }} + + + {{- with .date_started -}} Since - {{ time.Format "Jan 2, 2006" ( index . "Date Started" ) -}} + {{ time.Format "Jan 2, 2006" . -}} {{- else -}} Unknown {{- end -}} @@ -21,26 +23,28 @@

Diary

- {{ range ( sort ( where $.Site.Data.games.log "Date Finished" "!=" "" ) "Date Finished" "desc" ) }} + {{ range ( sort ( where $.Site.Data.games.log "date_finished" "!=" "" ) "date_finished" "desc" ) }} - TODO + {{ partial "games/rows/date_added.html" .date_added -}} - {{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" ) -}} + {{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" "title" .title "titleLang" .original_language "titleTrans" .original_title ) -}} - {{ .Platforms }} - {{ index . "Date Released" }} + {{- partial "games/rows/platforms.html" .platform -}} - {{- with index . "Level of Completion" }} + {{- partial "games/rows/release-date.html" .release_date }} + + + {{- with .level_of_completion }} {{ . }} {{- end -}} - {{- if index . "Date Started" -}} - {{- time.Format "Jan 2, 2006" ( index . "Date Started" ) -}} + {{- with .date_started -}} + {{- time.Format "Jan 2, 2006" . -}} {{- else -}} Unknown - {{- end -}}–{{- if index . "Date Finished" -}} - {{- time.Format "Jan 2, 2006" ( index . "Date Finished" ) -}} + {{- end -}}–{{- with .date_finished -}} + {{- time.Format "Jan 2, 2006" . -}} {{- else -}} Unknown {{- end -}} @@ -50,26 +54,28 @@

Assorted

- {{ range ( sort ( where $.Site.Data.games.log "Date Finished" "" ) "Title" "asc" ) }} + {{ range ( sort ( where $.Site.Data.games.log "date_finished" "" ) "title" "asc" ) }} - TODO + {{ partial "games/rows/date_added.html" .date_added -}} - {{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" ) -}} + {{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" "title" .title "titleLang" .original_language "titleTrans" .original_title ) -}} - {{ .Platforms }} - {{ index . "Date Released" }} + {{- partial "games/rows/platforms.html" .platform -}} - {{- with index . "Level of Completion" }} + {{- partial "games/rows/release-date.html" .release_date }} + + + {{- with .level_of_completion }} {{ . }} {{- end -}} - {{- if index . "Date Started" -}} - {{- time.Format "Jan 2, 2006" ( index . "Date Started" ) -}} + {{- with .date_started -}} + {{- time.Format "Jan 2, 2006" . -}} {{- else -}} Unknown - {{- end -}}–{{- if index . "Date Finished" -}} - {{- time.Format "Jan 2, 2006" ( index . "Date Finished" ) -}} + {{- end -}}–{{- with .date_finished -}} + {{- time.Format "Jan 2, 2006" . -}} {{- else -}} Unknown {{- end -}} @@ -77,14 +83,16 @@ {{ end }} {{ else if ( eq ( .Scratch.Get "listMode" ) "wishlist" ) }} - {{ range ( sort $.Site.Data.games.wishlist "Title" "asc" ) }} + {{ range ( sort $.Site.Data.games.wishlist "title" "asc" ) }} - TODO + {{ partial "games/rows/date_added.html" .date_added -}} {{- partial "cite" ( dict "c" . "g" $ "section" "games" "schemaType" "VideoGame" ) -}} - {{ .Platforms }} - {{ index . "Date Released" }} + {{- partial "games/rows/platforms.html" .platform -}} + + {{- partial "games/rows/release-date.html" .release_date }} + {{ end }} {{ end }}