posts.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. {{ if gt (len $page.Params.tags_include) 0 }}
  21. {{ $posts := where (where (where $.Data.Pages "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. {{ partial "post_li" $params }}
  39. {{end}}
  40. {{ end }}
  41. {{ else}}
  42. {{ $posts := where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil }}
  43. {{ $.Scratch.Add "show_post" "1" }}
  44. {{ range $post := first $page.Params.count $posts }}
  45. {{ $.Scratch.Set "show_post" "1" }}
  46. {{/* If `tags_include` is set, exclude posts with no tags. */}}
  47. {{ if and ($page.Params.tags_include) (lt (len .Params.tags) 1) }}
  48. {{ $.Scratch.Set "show_post" "0" }}
  49. {{end}}
  50. {{/* If `tags_exclude` is set, exclude posts. */}}
  51. {{ range $key, $val := .Params.tags }}
  52. {{ if in $page.Params.tags_exclude $val }}
  53. {{ $.Scratch.Set "show_post" "0" }}
  54. {{end}}
  55. {{end}}
  56. {{ $show_post := $.Scratch.Get "show_post" }}
  57. {{ if ne $show_post "0" }}
  58. {{ $params := dict "post" . }}
  59. {{ partial "post_li" $params }}
  60. {{end}}
  61. {{ end }}
  62. {{ end }}
  63. </div>
  64. </div>