pages.html 2.8 KB

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