pages.html 2.9 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 }}
  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 (use Hugo default for now) */}}
  34. {{/* $sort_by := "Date" */}}
  35. {{/* $query = sort $query $sort_by $items_sort */}}
  36. {{/* Offset and Limit */}}
  37. {{ if gt $items_offset 0 }}
  38. {{ $query = first $items_count (after $items_offset $query) }}
  39. {{ else }}
  40. {{ $query = first $items_count $query }}
  41. {{ end }}
  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>