posts.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {{ $ := .root }}
  2. {{ $page := .page }}
  3. {{ $posts_len := len (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
  4. <!-- Blog Posts widget -->
  5. <div class="row">
  6. <div class="col-xs-12 col-md-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="{{ "/post/" | relLangURL }}">
  12. {{ i18n "more_posts" | markdownify }}
  13. <i class="fa fa-angle-double-right"></i>
  14. </a>
  15. </p>
  16. {{ end }}
  17. </div>
  18. <div class="col-xs-12 col-md-8">
  19. {{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
  20. {{ $posts := where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil }}
  21. {{ if $page.Params.tags_include }}
  22. {{ $posts := where (where (where $.Data.Pages "Type" "post") ".Params.tags" "intersect" $page.Params.tags_include) ".Params.notonhomepage" nil }}
  23. {{ end }}
  24. {{ $.Scratch.Add "show_post" "1" }}
  25. {{ range $post := first $page.Params.count $posts }}
  26. {{ $.Scratch.Set "show_post" "1" }}
  27. {{/* If `tags_include` is set, exclude posts with no tags. */}}
  28. {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
  29. {{ $.Scratch.Set "show_post" "0" }}
  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" . "page" $page }}
  40. {{ partial "post_li" $params }}
  41. {{end}}
  42. {{ end }}
  43. </div>
  44. </div>