pages.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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" (urlize $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" (urlize $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.author }}
  31. {{ $archive_page = site.GetPage (printf "authors/%s" (urlize $st.Params.content.filters.author)) }}
  32. {{ $query = $query | intersect $archive_page.Pages }}
  33. {{ end }}
  34. {{ if $st.Params.content.filters.exclude_featured }}
  35. {{ $query = where $query "Params.featured" "!=" true }}
  36. {{ end }}
  37. {{ if $st.Params.content.filters.exclude_past }}
  38. {{ $query = where $query "Date" ">=" now }}
  39. {{ end }}
  40. {{ if $st.Params.content.filters.exclude_future }}
  41. {{ $query = where $query "Date" "<" now }}
  42. {{ end }}
  43. {{ $count := len $query }}
  44. {{/* Sort */}}
  45. {{ $sort_by := "Date" }}
  46. {{ $query = sort $query $sort_by $items_sort }}
  47. {{/* Offset and Limit */}}
  48. {{ if gt $items_offset 0 }}
  49. {{ $query = first $items_count (after $items_offset $query) }}
  50. {{ else }}
  51. {{ $query = first $items_count $query }}
  52. {{ end }}
  53. {{/* Localisation */}}
  54. {{ $i18n := "" }}
  55. {{ if eq $items_type "post" }}
  56. {{ $i18n = "more_posts" }}
  57. {{ else if eq $items_type "event" }}
  58. {{ $i18n = "more_talks" }}
  59. {{ else if eq $items_type "publication" }}
  60. {{ $i18n = "more_publications" }}
  61. {{ else }}
  62. {{ $i18n = "more_pages" }}
  63. {{ end }}
  64. {{ $columns := $st.Params.design.columns | default "2" }}
  65. <div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
  66. {{ with $st.Content }}{{ . }}{{ 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. {{/* Archive link */}}
  79. {{ $show_archive_link := $st.Params.content.archive.enable | default (gt $count $items_count) }}
  80. {{ if $show_archive_link }}
  81. {{ $archive_link := "" }}
  82. {{ if $st.Params.content.archive.link }}
  83. {{ $archive_link = $st.Params.content.archive.link | relLangURL }}
  84. {{ else }}
  85. {{ $archive_link = $archive_page.RelPermalink }}
  86. {{ end }}
  87. {{ $archive_text := $st.Params.content.archive.text | default (i18n $i18n) | default "See all" }}
  88. <div class="see-all">
  89. <a href="{{ $archive_link }}">
  90. {{ $archive_text | emojify }}
  91. <i class="fas fa-angle-right"></i>
  92. </a>
  93. </div>
  94. {{ end }}
  95. </div>