Bladeren bron

Do not show tags and category in side bar if metadata field is empty

It is possible if user do not set any value in it. Ideally he should
remove the metadata field but he may miss to do it.
Talha Mansoor 11 jaren geleden
bovenliggende
commit
02b6a9a7ed
1 gewijzigde bestanden met toevoegingen van 2 en 2 verwijderingen
  1. 2 2
      templates/article.html

+ 2 - 2
templates/article.html

@@ -84,11 +84,11 @@
             <time pubdate="pubdate" datetime="{{ article.date.isoformat() }}">{{ article.date.strftime('%b') }} {{ day }} {{- article.date.strftime(', %Y') }}</time>
             <time pubdate="pubdate" datetime="{{ article.date.isoformat() }}">{{ article.date.strftime('%b') }} {{ day }} {{- article.date.strftime(', %Y') }}</time>
             {% endif %}
             {% endif %}
             {% include 'last_updated.html' %}
             {% include 'last_updated.html' %}
-            {% if article.category %}
+            {% if article.category|trim|count > 0 %}
             <h4>Category</h4>
             <h4>Category</h4>
             <a class="category-link" href="{{ SITEURL }}/categories.html#{{ category.slug }}-ref">{{ article.category }}</a>
             <a class="category-link" href="{{ SITEURL }}/categories.html#{{ category.slug }}-ref">{{ article.category }}</a>
             {% endif %}
             {% endif %}
-            {% if article.tags %}
+            {% if article.tags and article.tags[0]|trim|count > 0 %}
             <h4>Tags</h4>
             <h4>Tags</h4>
             <ul class="list-of-tags tags-in-article">
             <ul class="list-of-tags tags-in-article">
                 {% for tag in article.tags|sort %}
                 {% for tag in article.tags|sort %}