last_updated.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {# code for Page and Article is exactly the same #}
  2. {% if article %}
  3. {# Check which version of Pelican user is using.
  4. If it is <=3.3 than modified is a string
  5. If it is >3.3 than modified is a datetime object
  6. #}
  7. {% if article.locale_modified and article.modified %}
  8. {# This check is necessary because modified is set to date by default.
  9. It should be displayed only if user has explicitly set it.
  10. #}
  11. {% if article.modified != article.date %}
  12. <h4>Last Updated</h4>
  13. {% set day = article.modified.strftime('%d')|int %}
  14. <time datetime="{{ article.modified.isoformat() }}">{{ article.modified.strftime('%b') }} {{ day }} {{- article.modified.strftime(', %Y') }}</time>
  15. {% endif %}
  16. {% elif article.modified %}
  17. <h4>Last Updated</h4>
  18. <div class="last-updated">{{ article.modified }}</div>
  19. {% endif %}
  20. {# code for Page #}
  21. {% elif page %}
  22. {% if page.locale_modified and page.modified %}
  23. {% if page.modified != page.date %}
  24. <h4>Last Updated</h4>
  25. {% set day = page.modified.strftime('%d')|int %}
  26. <time datetime="{{ page.modified.isoformat() }}">{{ page.modified.strftime('%b') }} {{ day }} {{- page.modified.strftime(', %Y') }}</time>
  27. {% endif %}
  28. {% elif page.modified %}
  29. <h4>Last Updated</h4>
  30. <div class="last-updated">{{ page.modified }}</div>
  31. {% endif %}
  32. {% endif %}