related.html 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <aside class="related">
  2. <h2>Related posts</h2>
  3. <ul class="related-posts">
  4. {% assign maxRelated = 4 %}
  5. {% assign minCommonTags = 2 %}
  6. {% assign maxRelatedCounter = 0 %}
  7. {% for post in site.posts %}
  8. {% assign sameTagCount = 0 %}
  9. {% assign commonTags = '' %}
  10. {% for tag in post.tags %}
  11. {% if post.url != page.url %}
  12. {% if page.tags contains tag %}
  13. {% assign sameTagCount = sameTagCount | plus: 1 %}
  14. {% capture tagmarkup %}
  15. <span class="label label-default">#{{ tag }}</span>
  16. {% endcapture %}
  17. {% assign commonTags = commonTags | append: tagmarkup %}
  18. {% endif %}
  19. {% endif %}
  20. {% endfor %}
  21. {% if sameTagCount >= minCommonTags %}
  22. {% include page/post-list-item.html %}
  23. {% assign maxRelatedCounter = maxRelatedCounter | plus: 1 %}
  24. {% if maxRelatedCounter >= maxRelated %}
  25. {% break %}
  26. {% endif %}
  27. {% endif %}
  28. {% endfor %}
  29. </aside>
  30. {% comment %}
  31. {{ commonTags }}
  32. {% endcomment %}