pages.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {{/* Pages Widget */}}
  2. {{/* Initialise */}}
  3. {{ $ := .root }}
  4. {{ $st := .page }}
  5. {{ $items_type := $st.Params.content.page_type | default "post" }}
  6. {{ $items_offset := $st.Params.content.offset | default 0 }}
  7. {{ $items_count := $st.Params.content.count }}
  8. {{ if eq $items_count 0 }}
  9. {{ $items_count = 65535 }}
  10. {{ else }}
  11. {{ $items_count = $items_count | default 5 }}
  12. {{ end }}
  13. {{ $items_sort := $st.Params.content.order | default "desc" }}
  14. {{/* Query */}}
  15. {{ $query := where site.RegularPages "Type" $items_type }}
  16. {{ $archive_page := site.GetPage "Section" $items_type }}
  17. {{/* Filters */}}
  18. {{ if $st.Params.content.filters.tag }}
  19. {{ $archive_page = site.GetPage (printf "tags/%s" $st.Params.content.filters.tag) }}
  20. {{ $query = $query | intersect $archive_page.Pages }}
  21. {{ end }}
  22. {{ if $st.Params.content.filters.category }}
  23. {{ $archive_page = site.GetPage (printf "categories/%s" $st.Params.content.filters.category) }}
  24. {{ $query = $query | intersect $archive_page.Pages }}
  25. {{ end }}
  26. {{ if $st.Params.content.filters.publication_type }}
  27. {{ $archive_page = site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }}
  28. {{ $query = $query | intersect $archive_page.Pages }}
  29. {{ end }}
  30. {{ if $st.Params.content.filters.exclude_featured }}
  31. {{ $query = where $query "Params.featured" "!=" true }}
  32. {{ end }}
  33. {{ if $st.Params.content.filters.exclude_past }}
  34. {{ $query = where $query "Date" ">=" now }}
  35. {{ end }}
  36. {{ if $st.Params.content.filters.exclude_future }}
  37. {{ $query = where $query "Date" "<" now }}
  38. {{ end }}
  39. {{ $count := len $query }}
  40. {{/* Sort */}}
  41. {{ $sort_by := "Date" }}
  42. {{ $query = sort $query $sort_by $items_sort }}
  43. {{/* Offset and Limit */}}
  44. {{ if gt $items_offset 0 }}
  45. {{ $query = first $items_count (after $items_offset $query) }}
  46. {{ else }}
  47. {{ $query = first $items_count $query }}
  48. {{ end }}
  49. {{/* Localisation */}}
  50. {{ $i18n := "" }}
  51. {{ if eq $items_type "post" }}
  52. {{ $i18n = "more_posts" }}
  53. {{ else if eq $items_type "talk" }}
  54. {{ $i18n = "more_talks" }}
  55. {{ else if eq $items_type "publication" }}
  56. {{ $i18n = "more_publications" }}
  57. {{ else }}
  58. {{ $i18n = "more_pages" }}
  59. {{ end }}
  60. <div class="row">
  61. <div class="col-12 col-lg-4 section-heading">
  62. <h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1>
  63. {{ with $st.Params.subtitle }}<p>{{ . | markdownify | emojify }}</p>{{ end }}
  64. </div>
  65. <div class="col-12 col-lg-8">
  66. {{ with $st.Content }}<p>{{ . }}</p>{{ end }}
  67. {{ range $post := $query }}
  68. {{ if eq $st.Params.design.view 1 }}
  69. {{ partial "li_list" . }}
  70. {{ else if eq $st.Params.design.view 3 }}
  71. {{ partial "li_card" . }}
  72. {{ else if eq $st.Params.design.view 4 | and (eq $items_type "publication") }}
  73. {{ partial "li_citation" . }}
  74. {{ else }}
  75. {{ partial "li_compact" . }}
  76. {{ end }}
  77. {{end}}
  78. {{ if gt $count $items_count }}
  79. <div class="see-all">
  80. <a href="{{ $archive_page.RelPermalink }}">
  81. {{ i18n $i18n | default "See all" }}
  82. <i class="fas fa-angle-right"></i>
  83. </a>
  84. </div>
  85. {{ end }}
  86. </div>
  87. </div>