Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.77 KB | None | 0 0
  1. ---
  2. layout: default
  3. ---
  4.  
  5. <article class="post">
  6.   <h1 class="post-title">{{ page.title }}</h1>
  7.   <time datetime="{{ page.date | date_to_xmlschema }}" class="post-date">{{ page.date | date_to_string }}</time>
  8.   {{ content }}
  9. </article>
  10.  
  11. <aside class="related">
  12. {% if site.related_posts != empty %}
  13.  
  14. {% assign maxRelated = 3 %}
  15. {% assign minCommonTags =  1 %}
  16. {% assign maxRelatedCounter = 0 %}
  17.   <h3>Похожие посты</h3>
  18.   <ul class="related-posts">
  19.     {% for post in site.posts %}
  20.  
  21.     {% assign sameTagCount = 0 %}
  22.     {% assign commonTags = '' %}
  23.  
  24.     {% for category in post.categories %}
  25.       {% if post.url != page.url %}
  26.         {% if page.categories contains category %}
  27.           {% assign sameTagCount = sameTagCount | plus: 1 %}
  28.           {% capture tagmarkup %}  {% endcapture %}
  29.           {% assign commonTags = commonTags | append: tagmarkup %}
  30.         {% endif %}
  31.       {% endif %}
  32.     {% endfor %}
  33.  
  34.     {% if sameTagCount >= minCommonTags %}
  35.    
  36.       <li><a href="{{ site.baseurl }}{{ post.url }}">
  37.         {{ post.title }}{{ commonTags }}
  38.           <small><time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date_to_string }}</time></small>        
  39.       </a></li>
  40.      
  41.       {% assign maxRelatedCounter = maxRelatedCounter | plus: 1 %}
  42.       {% if maxRelatedCounter >= maxRelated %}
  43.         {% break %}
  44.       {% endif %}
  45.     {% endif %}
  46.  
  47.   {% endfor %}
  48.  
  49. {% if sameTagCount == 0 %} {% for post in site.related_posts limit:3 %}
  50.   <li>
  51.     <a href="{{ site.baseurl }}{{ post.url }}">
  52.             {{ post.title }}
  53.             <small><time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date_to_string }}</time></small>
  54.           </a>
  55.   </li>
  56. {% endfor %} {% endif %}
  57.  
  58.   </ul>
  59. </aside>
  60. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement