small fixes

This commit is contained in:
teldra 2022-04-08 14:42:30 +02:00
parent 52da0b8919
commit f5944d423c
2 changed files with 27 additions and 47 deletions

View File

@ -6,9 +6,10 @@
{{ define "main" }} {{ define "main" }}
{{ $s := .Site.Params }} {{ $s := .Site.Params }}
{{- $posts := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" $s.searchSections }} {{- $all := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" $s.searchSections }}
{{- $featured := where (where $posts ".Params.featured" "=" true) "Type" "in" $s.searchSections }} {{ $featured := where (where (where $all ".Params.featured" "=" true) "Type" "in" $s.searchSections) ".Params.Lastmod" "gt" (now.AddDate 0 0 -14) }}
{{ $featured = where $featured ".Params.Lastmod" "gt" (now.AddDate 0 0 -14) }} {{ $featured = $all | intersect $featured }}
{{ $posts := $all | complement $featured }}
{{- $paginator := .Paginate $posts -}} {{- $paginator := .Paginate $posts -}}
{{ if eq $paginator.PageNumber 1 }} {{ if eq $paginator.PageNumber 1 }}
{{ if ne .Content "" }} {{ if ne .Content "" }}
@ -18,12 +19,12 @@
{{ end }} {{ end }}
{{ if gt (len $featured) 0 }} {{ if gt (len $featured) 0 }}
<a href="/featured"><h2>{{if "featured" | i18n }}{{ "featured" | i18n }}{{ else }}{{ "Featured" }}{{ end }}</h2></a> <a href="/featured"><h2>{{if "featured" | i18n }}{{ "featured" | i18n }}{{ else }}{{ "Featured" }}{{ end }}</h2></a>
{{ partial "contentlayouts/list.html" (dict "context" . "pages" $featured "amount" "3" "max_age" "14" "featured" "true") }} {{ partial "contentlayouts/list.html" (dict "context" . "pages" $featured "amount" "3" ) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if gt (len $posts) 1 }} {{ if gt (len $posts) 1 }}
<a href="/news"><h2>{{ if "news" | i18n }}{{ "news" | i18n }}{{ else }}{{ "News" }}{{ end }}</h2></a> <a href="/news"><h2>{{ if "news" | i18n }}{{ "news" | i18n }}{{ else }}{{ "News" }}{{ end }}</h2></a>
{{ partial "contentlayouts/list.html" (dict "context" . "paginator" $paginator "amount" "5" "max_age" "-14") }} {{ partial "contentlayouts/list.html" (dict "context" . "paginator" $paginator "amount" "5") }}
<div id="pagination_outer" style="display: flex; justify-content: center;"> <div id="pagination_outer" style="display: flex; justify-content: center;">
{{ partial "structure/paginator" (dict "paginator" $paginator) }} {{ partial "structure/paginator" (dict "paginator" $paginator) }}

View File

@ -1,44 +1,23 @@
{{ if or .paginator .pages }} {{ if and .amount (or .paginator .pages) }}
{{ if .amount }} {{ $amount := .amount }}
{{ $amount := .amount }} {{ $pages := "" }}
{{ $pages := "" }} {{ if .pages }}
{{ $max_age := int .max_age }} {{ $pages = .pages.ByLastmod.Reverse }}
{{ $featured := .featured }} {{ else if .paginator }}
{{ if .pages }} {{ $pages = .paginator.Pages.ByLastmod.Reverse }}
{{ $pages = .pages.ByLastmod.Reverse }} {{ end }}
{{ else if .paginator }} {{- range first $amount $pages -}}
{{ $pages = .paginator.Pages.ByLastmod.Reverse }} <article class="articlebgcol1 borderrad25">
{{ end }} <a href="{{- .Permalink -}}">
{{- range first $amount $pages -}} <div id="articletitle">
{{ $true := true }} <h2>{{- .Title -}}</h2>
</div>
{{ if $featured }} </a>
{{ if le (.Lastmod.AddDate 0 0 $max_age) now }} <a href="{{- .Permalink -}}">
{{ $true = false }} <div id="articlecontent">
{{ end }} {{ partial "contentlayouts/article.html" (dict "context" . "type" "list") }}
{{ else }} </div>
{{ if $max_age }} </a>
{{ if and (lt (.Lastmod.AddDate 0 0 $max_age) now) (eq .Params.featured true) }} </article>
{{ $true = false }}
{{ end }}
{{ end }}
{{ end }}
{{ if eq $true true }}
{{ if .Title }}
<article class="articlebgcol1 borderrad25">
<a href="{{- .Permalink -}}">
<div id="articletitle">
<h2>{{- .Title -}}</h2>
</div>
</a>
<a href="{{- .Permalink -}}">
<div id="articlecontent">
{{ partial "contentlayouts/article.html" (dict "context" . "type" "list") }}
</div>
</a>
</article>
{{ end }}
{{ end }}
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}