posts.html 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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").RelPermalink }}">
  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. {{ with (not .Params.tags) }}
  27. {{ with $page.Params.tags_include }}
  28. {{ $.Scratch.Set "show_post" "0" }}
  29. {{end}}
  30. {{end}}
  31. {{/* If `tags_exclude` is set, exclude posts. */}}
  32. {{ range $key, $val := .Params.tags }}
  33. {{ if in $page.Params.tags_exclude $val }}
  34. {{ $.Scratch.Set "show_post" "0" }}
  35. {{end}}
  36. {{end}}
  37. {{ $show_post := $.Scratch.Get "show_post" }}
  38. {{ if ne $show_post "0" }}
  39. {{ $params := dict "post" . }}
  40. {{ if eq $page.Params.list_format 0 }}
  41. {{ partial "post_li_simple" $params }}
  42. {{ else if eq $page.Params.list_format 1 }}
  43. {{ partial "post_li_detailed" $params }}
  44. {{ else }}
  45. {{ partial "post_li_stream" $params }}
  46. {{ end }}
  47. {{end}}
  48. {{ end }}
  49. {{ else}}
  50. {{ $posts := where (where $.Site.RegularPages "Type" "post") ".Params.notonhomepage" nil }}
  51. {{ $.Scratch.Add "show_post" "1" }}
  52. {{ range $post := first $page.Params.count $posts }}
  53. {{ $.Scratch.Set "show_post" "1" }}
  54. {{/* If `tags_include` is set, exclude posts with no tags. */}}
  55. {{ with (not .Params.tags) }}
  56. {{ with $page.Params.tags_include }}
  57. {{ $.Scratch.Set "show_post" "0" }}
  58. {{end}}
  59. {{end}}
  60. {{/* If `tags_exclude` is set, exclude posts. */}}
  61. {{ range $key, $val := .Params.tags }}
  62. {{ if in $page.Params.tags_exclude $val }}
  63. {{ $.Scratch.Set "show_post" "0" }}
  64. {{end}}
  65. {{end}}
  66. {{ $show_post := $.Scratch.Get "show_post" }}
  67. {{ if ne $show_post "0" }}
  68. {{ $params := dict "post" . }}
  69. {{ if eq $page.Params.list_format 0 }}
  70. {{ partial "post_li_simple" $params }}
  71. {{ else if eq $page.Params.list_format 1 }}
  72. {{ partial "post_li_detailed" $params }}
  73. {{ else }}
  74. {{ partial "post_li_stream" $params }}
  75. {{ end }}
  76. {{end}}
  77. {{ end }}
  78. {{ end }}
  79. </div>
  80. </div>