featured.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. {{ $count := len $query }}
  29. {{/* Sort */}}
  30. {{ $sort_by := "Date" }}
  31. {{ $query = sort $query $sort_by $items_sort }}
  32. {{/* Limit */}}
  33. {{ $query = first $items_count $query }}
  34. {{/* Localisation */}}
  35. {{ $i18n := "" }}
  36. {{ if eq $items_type "post" }}
  37. {{ $i18n = "more_posts" }}
  38. {{ else if eq $items_type "event" }}
  39. {{ $i18n = "more_talks" }}
  40. {{ else if eq $items_type "publication" }}
  41. {{ $i18n = "more_publications" }}
  42. {{ else }}
  43. {{ $i18n = "more_pages" }}
  44. {{ end }}
  45. {{ $columns := $st.Params.design.columns | default "2" }}
  46. <div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
  47. {{ with $st.Content }}{{ . }}{{ end }}
  48. {{ range $index, $post := $query }}
  49. {{ partial "functions/render_view" (dict "page" $st "item" . "view" ($st.Params.design.view | default "compact") "index" $index) }}
  50. {{end}}
  51. {{/* Archive link */}}
  52. {{ $show_archive_link := $st.Params.content.archive.enable | default (gt $count $items_count) }}
  53. {{ if $show_archive_link }}
  54. {{ $archive_link := "" }}
  55. {{ if $st.Params.content.archive.link }}
  56. {{ $archive_link = $st.Params.content.archive.link | relLangURL }}
  57. {{ else }}
  58. {{ $archive_link = $archive_page.RelPermalink }}
  59. {{ end }}
  60. {{ $archive_text := $st.Params.content.archive.text | default (i18n $i18n) | default "See all" }}
  61. <div class="see-all">
  62. <a href="{{ $archive_link }}">
  63. {{ $archive_text | emojify }}
  64. <i class="fas fa-angle-right"></i>
  65. </a>
  66. </div>
  67. {{ end }}
  68. </div>