portfolios_exemple2/layouts/partials/widgets/pages.html

101 lines
3.1 KiB
HTML
Raw Permalink Normal View History

2021-12-31 12:44:26 +01:00
{{/* Pages Widget */}}
{{/* Initialise */}}
{{ $ := .root }}
{{ $st := .page }}
{{ $items_type := $st.Params.content.page_type | default "post" }}
{{ $items_offset := $st.Params.content.offset | default 0 }}
{{ $items_count := $st.Params.content.count }}
{{ if eq $items_count 0 }}
{{ $items_count = 65535 }}
{{ else }}
{{ $items_count = $items_count | default 5 }}
{{ end }}
{{ $items_sort := $st.Params.content.order | default "desc" }}
{{/* Query */}}
{{ $query := where site.RegularPages "Type" $items_type }}
{{ $archive_page := site.GetPage "Section" $items_type }}
{{/* Filters */}}
{{ if $st.Params.content.filters.tag }}
{{ $archive_page = site.GetPage (printf "tags/%s" $st.Params.content.filters.tag) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ end }}
{{ if $st.Params.content.filters.category }}
{{ $archive_page = site.GetPage (printf "categories/%s" $st.Params.content.filters.category) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ end }}
{{ if $st.Params.content.filters.publication_type }}
{{ $archive_page = site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ end }}
{{ if $st.Params.content.filters.exclude_featured }}
{{ $query = where $query "Params.featured" "!=" true }}
{{ end }}
{{ if $st.Params.content.filters.exclude_past }}
{{ $query = where $query "Date" ">=" now }}
{{ end }}
{{ if $st.Params.content.filters.exclude_future }}
{{ $query = where $query "Date" "<" now }}
{{ end }}
{{ $count := len $query }}
{{/* Sort */}}
{{ $sort_by := "Date" }}
{{ $query = sort $query $sort_by $items_sort }}
{{/* Offset and Limit */}}
{{ if gt $items_offset 0 }}
{{ $query = first $items_count (after $items_offset $query) }}
{{ else }}
{{ $query = first $items_count $query }}
{{ end }}
{{/* Localisation */}}
{{ $i18n := "" }}
{{ if eq $items_type "post" }}
{{ $i18n = "more_posts" }}
{{ else if eq $items_type "talk" }}
{{ $i18n = "more_talks" }}
{{ else if eq $items_type "publication" }}
{{ $i18n = "more_publications" }}
{{ else }}
{{ $i18n = "more_pages" }}
{{ end }}
<div class="row">
<div class="col-12 section-heading text-center">
<h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1>
{{ with $st.Params.subtitle }}<p>{{ . | markdownify | emojify }}</p>{{ end }}
{{ with $st.Content }}<p>{{ . }}</p>{{ end }}
</div>
<div class="col-12">
<div class="row justify-content-center">
{{ range $post := $query }}
{{ if eq $st.Params.design.view 1 }}
{{ partial "li_list" . }}
{{ else if eq $st.Params.design.view 3 }}
<div class="col-lg-4 col-md-6 mb-4">
{{ partial "li_card" . }}
</div>
{{ else if eq $st.Params.design.view 4 | and (eq $items_type "publication") }}
{{ partial "li_citation" . }}
{{ else }}
{{ partial "li_compact" . }}
{{ end }}
{{end}}
{{ if gt $count $items_count }}
<div class="see-all">
<a href="{{ $archive_page.RelPermalink }}">
{{ i18n $i18n | default "See all" }}
<i class="fas fa-angle-right"></i>
</a>
</div>
{{ end }}
</div>
</div>
</div>