featured.html 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 (use Hugo default for now) */}}
  24. {{/* $sort_by := "Date" */}}
  25. {{/* $query = sort $query $sort_by $items_sort */}}
  26. {{/* Limit */}}
  27. {{ $query = first $items_count $query }}
  28. <div class="row">
  29. <div class="col-12 col-lg-4 section-heading">
  30. <h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1>
  31. {{ with $st.Params.subtitle }}<p>{{ . | markdownify | emojify }}</p>{{ end }}
  32. </div>
  33. <div class="col-12 col-lg-8">
  34. {{ with $st.Content }}<p>{{ . }}</p>{{ end }}
  35. {{ range $post := $query }}
  36. {{ if eq $st.Params.design.view 1 }}
  37. {{ partial "li_list" . }}
  38. {{ else if eq $st.Params.design.view 3 }}
  39. {{ partial "li_card" . }}
  40. {{ else if eq $st.Params.design.view 3 | and (eq $st.Type "publication") }}
  41. {{ partial "li_citation" . }}
  42. {{ else }}
  43. {{ partial "li_compact" . }}
  44. {{ end }}
  45. {{end}}
  46. </div>
  47. </div>