Переглянути джерело

Add support for related posts

Fix #101
Talha Mansoor 11 роки тому
батько
коміт
a32b9c0f57
2 змінених файлів з 19 додано та 0 видалено
  1. 18 0
      templates/_includes/related_posts.html
  2. 1 0
      templates/article.html

+ 18 - 0
templates/_includes/related_posts.html

@@ -0,0 +1,18 @@
+{% if article.related_posts %}
+<section>
+<h2>Read this next</h2>
+<ul>
+{% for related_post in article.related_posts %}
+    {% set title = related_post.title|striptags %}
+    {% set htitle = title %}
+    {%if related_post.subtitle %}
+        {% set htitle = title + ' - ' + related_post.subtitle %}
+        {% set title = title + ' ' +  '<small>' + related_post.subtitle + '</small>' %}
+    {% endif %}
+<li><a href="{{ SITEURL }}/{{ related_post.url }}" title="{{ htitle }}">{{ title }}</a></li>
+{% endfor %}
+</ul>
+<hr />
+</section>
+{% endif %}
+

+ 1 - 0
templates/article.html

@@ -43,6 +43,7 @@
             {% from '_includes/comments.html' import comments with context %}
             {{ comments(article) }}
             <hr/>
+            {% include '_includes/related_posts.html' with context %}
             {% if article.prev_article or article.next_article %}
             <aside>
             <nav>