feat(list): display subsections in list style when there are no normal pages (#121)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/116
This commit is contained in:
parent
90e259f31e
commit
70cc14fcbe
@ -42,8 +42,17 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ $subsections := .Sections }}
|
{{- $subsections := .Sections -}}
|
||||||
{{ with $subsections }}
|
{{- $pages := .Pages | complement $subsections -}}
|
||||||
|
|
||||||
|
{{- if eq (len $pages) 0 -}}
|
||||||
|
{{/* If there are no normal pages, display subsections in list style, with pagination */}}
|
||||||
|
{{/* This happens with taxonomies like categories or tags */}}
|
||||||
|
{{- $pages = $subsections -}}
|
||||||
|
{{- $subsections = slice -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- with $subsections -}}
|
||||||
<h2 class="section-title">{{ T "list.subsection" (len $subsections) }}</h2>
|
<h2 class="section-title">{{ T "list.subsection" (len $subsections) }}</h2>
|
||||||
<div class="subsection-list">
|
<div class="subsection-list">
|
||||||
<div class="article-list--tile">
|
<div class="article-list--tile">
|
||||||
@ -52,10 +61,10 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
|
|
||||||
{{/* List only pages that are not a subsection */}}
|
{{/* List only pages that are not a subsection */}}
|
||||||
{{ $paginator := .Paginate (.Pages | complement $subsections) }}
|
{{ $paginator := .Paginate $pages }}
|
||||||
<section class="article-list--compact">
|
<section class="article-list--compact">
|
||||||
{{ range $paginator.Pages }}
|
{{ range $paginator.Pages }}
|
||||||
{{ partial "article-list/compact" . }}
|
{{ partial "article-list/compact" . }}
|
||||||
|
Loading…
Reference in New Issue
Block a user