From 942ef76fc9cdac8bda8ace1fb5675494c99cf18f Mon Sep 17 00:00:00 2001 From: Denys Konovalov Date: Sun, 24 Mar 2024 16:11:29 +0100 Subject: [PATCH] fix date sorting --- layouts/index.html | 4 ++-- layouts/partials/data/termin-upcoming.html | 1 + layouts/partials/header.html | 2 +- layouts/partials/related.html | 3 +-- layouts/termine/list.html | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 layouts/partials/data/termin-upcoming.html diff --git a/layouts/index.html b/layouts/index.html index 2d35157d..40aa84cb 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -224,8 +224,8 @@ {{ with .Site.GetPage "/termine/_index.md" }} {{ $events := slice }} - {{ range .Params.events }} - {{ if or (ge (.date | time.AsTime).Unix now.Unix) (and .enddate (ge (.enddate | time.AsTime).Unix now.Unix)) }} + {{ range sort .Params.events ".date" }} + {{ if partial "data/termin-upcoming" . }} {{ $events = $events | append . }} {{ end }} {{ end }} diff --git a/layouts/partials/data/termin-upcoming.html b/layouts/partials/data/termin-upcoming.html new file mode 100644 index 00000000..3d093194 --- /dev/null +++ b/layouts/partials/data/termin-upcoming.html @@ -0,0 +1 @@ +{{ return or (ge (.date | time.AsTime) now) (and .enddate (ge (.enddate | time.AsTime) now)) }} \ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 5993a5d6..c72db478 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -86,7 +86,7 @@ {{ $top_banner := .Site.Data.homepage.top_banner }} {{ if and $top_banner.enable }} - {{ if or (not $top_banner.temporarily.enable) (and $top_banner.temporarily.enable (and (le ($top_banner.temporarily.start_date | time.AsTime).Unix now.Unix ) (ge ($top_banner.temporarily.end_date | time.AsTime).Unix now.Unix))) }} + {{ if or (not $top_banner.temporarily.enable) (and $top_banner.temporarily.enable (and (le ($top_banner.temporarily.start_date | time.AsTime) now) (ge ($top_banner.temporarily.end_date | time.AsTime) now))) }} {{ with $top_banner }}
diff --git a/layouts/partials/related.html b/layouts/partials/related.html index 6d16a26e..e5471417 100644 --- a/layouts/partials/related.html +++ b/layouts/partials/related.html @@ -1,2 +1 @@ -{{ $related := (where .Site.RegularPages "Type" .Type) | intersect (where .Site.Pages ".Title" "!=" .Title) | union (.Site.RegularPages.Related . ) | shuffle | first 3 }} -{{ return $related }} \ No newline at end of file +{{ return (where .Site.RegularPages "Type" .Type) | intersect (where .Site.Pages ".Title" "!=" .Title) | union (.Site.RegularPages.Related . ) | shuffle | first 3 }} \ No newline at end of file diff --git a/layouts/termine/list.html b/layouts/termine/list.html index 595a7acd..493bcbe7 100644 --- a/layouts/termine/list.html +++ b/layouts/termine/list.html @@ -8,8 +8,8 @@
  • Vergangen
  • - {{ range .Params.events }} -
    + {{ range sort .Params.events ".date" }} +
    {{ partial "termin" . }}
    {{ end }}