posts.html 3.1 KB

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