posts.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. {{ $ := .root }}
  2. {{ $page := .page }}
  3. {{ $posts_len := len (where (where $.Site.RegularPages "Type" "post") ".Params.notonhomepage" nil) }}
  4. <!-- Blog Posts widget -->
  5. <div class="row">
  6. <div class="col-12 col-lg-4 section-heading">
  7. <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
  8. {{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
  9. {{ if gt $posts_len $page.Params.count }}
  10. <p class="view-all">
  11. <a href="{{ ($.Site.GetPage "section" "post").Permalink }}">
  12. {{ i18n "more_posts" | markdownify }}
  13. <i class="fas fa-angle-double-right"></i>
  14. </a>
  15. </p>
  16. {{ end }}
  17. </div>
  18. <div class="col-12 col-lg-8">
  19. {{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
  20. {{ if gt (len $page.Params.tags_include) 0 }}
  21. {{ $posts := where (where (where $.Site.RegularPages "Type" "post") ".Params.tags" "intersect" $page.Params.tags_include) ".Params.notonhomepage" nil }}
  22. {{ $.Scratch.Add "show_post" "1" }}
  23. {{ range $post := first $page.Params.count $posts }}
  24. {{ $.Scratch.Set "show_post" "1" }}
  25. {{/* If `tags_include` is set, exclude posts with no tags. */}}
  26. {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
  27. {{ $.Scratch.Set "show_post" "0" }}
  28. {{end}}
  29. {{/* If `tags_exclude` is set, exclude posts. */}}
  30. {{ range $key, $val := .Params.tags }}
  31. {{ if in $page.Params.tags_exclude $val }}
  32. {{ $.Scratch.Set "show_post" "0" }}
  33. {{end}}
  34. {{end}}
  35. {{ $show_post := $.Scratch.Get "show_post" }}
  36. {{ if ne $show_post "0" }}
  37. {{ $params := dict "post" . }}
  38. {{ if eq $page.Params.list_format 0 }}
  39. {{ partial "post_li_simple" $params }}
  40. {{ else }}
  41. {{ partial "post_li_detailed" $params }}
  42. {{ end }}
  43. {{end}}
  44. {{ end }}
  45. {{ else}}
  46. {{ $posts := where (where $.Site.RegularPages "Type" "post") ".Params.notonhomepage" nil }}
  47. {{ $.Scratch.Add "show_post" "1" }}
  48. {{ range $post := first $page.Params.count $posts }}
  49. {{ $.Scratch.Set "show_post" "1" }}
  50. {{/* If `tags_include` is set, exclude posts with no tags. */}}
  51. {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
  52. {{ $.Scratch.Set "show_post" "0" }}
  53. {{end}}
  54. {{/* If `tags_exclude` is set, exclude posts. */}}
  55. {{ range $key, $val := .Params.tags }}
  56. {{ if in $page.Params.tags_exclude $val }}
  57. {{ $.Scratch.Set "show_post" "0" }}
  58. {{end}}
  59. {{end}}
  60. {{ $show_post := $.Scratch.Get "show_post" }}
  61. {{ if ne $show_post "0" }}
  62. {{ $params := dict "post" . }}
  63. {{ if eq $page.Params.list_format 0 }}
  64. {{ partial "post_li_simple" $params }}
  65. {{ else }}
  66. {{ partial "post_li_detailed" $params }}
  67. {{ end }}
  68. {{end}}
  69. {{ end }}
  70. {{ end }}
  71. </div>
  72. </div>