pages.html 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.filters.content.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.filters.content.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. {{/* Sort */}}
  34. {{ $sort_by := "" }}
  35. {{ if eq $items_type "talk" }}
  36. {{ $sort_by = "Params.time_start" }}
  37. {{ else }}
  38. {{ $sort_by = "Date" }}
  39. {{ end }}
  40. {{ $query = sort $query $sort_by $items_sort }}
  41. {{/* Offset and Limit */}}
  42. {{ if gt $items_offset 0 }}
  43. {{ $query = first $items_count (after $items_offset $query) }}
  44. {{ else }}
  45. {{ $query = first $items_count $query }}
  46. {{ end }}
  47. {{ $count := len $query }}
  48. {{/* Localisation */}}
  49. {{ $i18n := "" }}
  50. {{ if eq $items_type "post" }}
  51. {{ $i18n = "more_posts" }}
  52. {{ else if eq $items_type "talk" }}
  53. {{ $i18n = "more_talks" }}
  54. {{ else if eq $items_type "publication" }}
  55. {{ $i18n = "more_publications" }}
  56. {{ else }}
  57. {{ $i18n = "more_pages" }}
  58. {{ end }}
  59. <div class="row">
  60. <div class="col-12 col-lg-4 section-heading">
  61. <h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1>
  62. {{ with $st.Params.subtitle }}<p>{{ . | markdownify | emojify }}</p>{{ end }}
  63. </div>
  64. <div class="col-12 col-lg-8">
  65. {{ with $st.Content }}<p>{{ . }}</p>{{ end }}
  66. {{ range $post := $query }}
  67. {{ if eq $st.Params.design.view 1 }}
  68. {{ partial "li_list" . }}
  69. {{ else if eq $st.Params.design.view 3 }}
  70. {{ partial "li_card" . }}
  71. {{ else if eq $st.Params.design.view 3 | and (eq $st.Type "publication") }}
  72. {{ partial "li_citation" . }}
  73. {{ else }}
  74. {{ partial "li_compact" . }}
  75. {{ end }}
  76. {{end}}
  77. {{ if gt $count $items_count }}
  78. <div class="see-all">
  79. <a href="{{ $archive_page.RelPermalink }}">
  80. {{ i18n $i18n | default "See all" }}
  81. <i class="fas fa-angle-right"></i>
  82. </a>
  83. </div>
  84. {{ end }}
  85. </div>
  86. </div>