featured.html 2.7 KB

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