featured.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. {{/* Filters */}}
  11. {{ if $st.Params.content.filters.tag }}
  12. {{ $archive_page := $.Site.GetPage (printf "tags/%s" $st.Params.filters.content.tag) }}
  13. {{ $query = $query | intersect $archive_page.Pages }}
  14. {{ end }}
  15. {{ if $st.Params.content.filters.category }}
  16. {{ $archive_page := $.Site.GetPage (printf "categories/%s" $st.Params.filters.content.category) }}
  17. {{ $query = $query | intersect $archive_page.Pages }}
  18. {{ end }}
  19. {{ if $st.Params.content.filters.publication_type }}
  20. {{ $archive_page := $.Site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }}
  21. {{ $query = $query | intersect $archive_page.Pages }}
  22. {{ end }}
  23. {{/* Sort */}}
  24. {{ $sort_by := "" }}
  25. {{ if eq $items_type "talk" }}
  26. {{ $sort_by = "Params.time_start" }}
  27. {{ else }}
  28. {{ $sort_by = "Date" }}
  29. {{ end }}
  30. {{ $query = sort $query $sort_by $items_sort }}
  31. {{/* Limit */}}
  32. {{ $query = first $items_count $query }}
  33. <div class="row">
  34. <div class="col-12 col-lg-4 section-heading">
  35. <h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1>
  36. {{ with $st.Params.subtitle }}<p>{{ . | markdownify | emojify }}</p>{{ end }}
  37. </div>
  38. <div class="col-12 col-lg-8">
  39. {{ with $st.Content }}<p>{{ . }}</p>{{ end }}
  40. {{ range $post := $query }}
  41. {{ if eq $st.Params.design.view 1 }}
  42. {{ partial "li_list" . }}
  43. {{ else if eq $st.Params.design.view 3 }}
  44. {{ partial "li_card" . }}
  45. {{ else if eq $st.Params.design.view 3 | and (eq $st.Type "publication") }}
  46. {{ partial "li_citation" . }}
  47. {{ else }}
  48. {{ partial "li_compact" . }}
  49. {{ end }}
  50. {{end}}
  51. </div>
  52. </div>