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 }}
|
||||
</div>
|
||||
|
||||
{{ $subsections := .Sections }}
|
||||
{{ with $subsections }}
|
||||
{{- $subsections := .Sections -}}
|
||||
{{- $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>
|
||||
<div class="subsection-list">
|
||||
<div class="article-list--tile">
|
||||
@ -52,10 +61,10 @@
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* List only pages that are not a subsection */}}
|
||||
{{ $paginator := .Paginate (.Pages | complement $subsections) }}
|
||||
{{ $paginator := .Paginate $pages }}
|
||||
<section class="article-list--compact">
|
||||
{{ range $paginator.Pages }}
|
||||
{{ partial "article-list/compact" . }}
|
||||
|
Loading…
Reference in New Issue
Block a user