list.html 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {{ define "main" }}
  2. <header>
  3. <h3 class="section-title">
  4. {{ if eq .Parent (.GetPage "/") }}
  5. {{ T "list.section" }}
  6. {{ else }}
  7. {{ .Parent.Title }}
  8. {{ end }}
  9. </h3>
  10. <div class="section-card">
  11. <div class="section-details">
  12. <h3 class="section-count">{{ T "list.page" (len .Pages) }}</h3>
  13. <h1 class="section-term">{{ .Title }}</h1>
  14. {{ with .Params.description }}
  15. <h2 class="section-description">{{ . }}</h2>
  16. {{ end }}
  17. </div>
  18. {{- $image := partialCached "helper/image" (dict "Context" . "Type" "section") .RelPermalink "section" -}}
  19. {{ if $image.exists }}
  20. <div class="section-image">
  21. {{ if $image.resource }}
  22. {{- $Permalink := $image.resource.RelPermalink -}}
  23. {{- $Width := $image.resource.Width -}}
  24. {{- $Height := $image.resource.Height -}}
  25. {{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
  26. {{- $thumbnail := $image.resource.Fill "120x120" -}}
  27. {{- $Permalink = $thumbnail.RelPermalink -}}
  28. {{- $Width = $thumbnail.Width -}}
  29. {{- $Height = $thumbnail.Height -}}
  30. {{- end -}}
  31. <img src="{{ $Permalink }}"
  32. width="{{ $Width }}"
  33. height="{{ $Height }}"
  34. loading="lazy">
  35. {{ else }}
  36. <img src="{{ $image.permalink }}" loading="lazy" />
  37. {{ end }}
  38. </div>
  39. {{ end }}
  40. </div>
  41. </header>
  42. {{- $subsections := .Sections -}}
  43. {{- $pages := .Pages | complement $subsections -}}
  44. {{- if eq (len $pages) 0 -}}
  45. {{/* If there are no normal pages, display subsections in list style, with pagination */}}
  46. {{/* This happens with taxonomies like categories or tags */}}
  47. {{- $pages = $subsections -}}
  48. {{- $subsections = slice -}}
  49. {{- end -}}
  50. {{- with $subsections -}}
  51. <aside>
  52. <h2 class="section-title">{{ T "list.subsection" (len $subsections) }}</h2>
  53. <div class="subsection-list">
  54. <div class="article-list--tile">
  55. {{ range . }}
  56. {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "section") }}
  57. {{ end }}
  58. </div>
  59. </div>
  60. </aside>
  61. {{- end -}}
  62. {{/* List only pages that are not a subsection */}}
  63. {{ $paginator := .Paginate $pages }}
  64. <section class="article-list--compact">
  65. {{ range $paginator.Pages }}
  66. {{ partial "article-list/compact" . }}
  67. {{ end }}
  68. </section>
  69. {{- partial "pagination.html" . -}}
  70. {{ partialCached "footer/footer" . }}
  71. {{ end }}
  72. {{ define "right-sidebar" }}
  73. {{ partial "sidebar/right.html" (dict "Context" . "Scope" "homepage") }}
  74. {{ end }}