Readme.rst 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Dateish Plugin for Pelican
  2. ==========================
  3. This plugin adds the ability to treat arbitrary metadata fields as datetime
  4. objects.
  5. Usage
  6. -----
  7. For example, if you have the following pieces of metadata in an article:
  8. .. code-block:: markdown
  9. # my_article.markdown
  10. Date: 2000-01-01
  11. Idea_Date: 1993-03-04
  12. Important_Dates: 2013-10-12
  13. 2013-11-08
  14. 2013-12-02
  15. Normally, the Idea_Date and Important_Dates variables will be strings, so
  16. you will not be able to use the strftime() Jinja filter on them.
  17. With this plugin, you define in your settings file a list of the names of
  18. the additional metadata fields you want to treat as dates:
  19. .. code-block:: python
  20. # pelicanconf.py
  21. DATEISH_PROPERTIES = ['idea_date', 'important_dates']
  22. Then you can use them in templates just like date:
  23. .. code-block:: html+jinja
  24. # mytemplate.html
  25. <p>Idea date: {{ article.idea_date | strftime('%d %B %Y') }}</p>
  26. {% for d in article.important_dates %}
  27. <p>Important date: {{ d | strftime('%d %B %Y') }}</p>
  28. {% endfor %}