mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 04:03:48 +01:00
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
1 changed files with 13 additions and 4 deletions
|
@ -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 a new issue