Jesús d81f06b3f8 [neighbors] Fix iter3() error on Python 3.7 and pass flake8 5 år sedan
..
LICENSE 9bbe38df58 first commit 5 år sedan
Readme.rst 9bbe38df58 first commit 5 år sedan
__init__.py 9bbe38df58 first commit 5 år sedan
neighbors.py d81f06b3f8 [neighbors] Fix iter3() error on Python 3.7 and pass flake8 5 år sedan

Readme.rst

Neighbor Articles Plugin for Pelican
====================================

This plugin adds ``next_article`` (newer) and ``prev_article`` (older)
variables to the article's context.

Also adds ``next_article_in_category`` and ``prev_article_in_category``.


Usage
-----

.. code-block:: html+jinja


    {% if article.prev_article %}


  • {{ article.prev_article.title }}


  • {% endif %}
    {% if article.next_article %}


  • {{ article.next_article.title }}


  • {% endif %}


    {% if article.prev_article_in_category %}


  • {{ article.prev_article_in_category.title }}


  • {% endif %}
    {% if article.next_article_in_category %}


  • {{ article.next_article_in_category.title }}


  • {% endif %}


Usage with the Subcategory plugin
---------------------------------

If you want to get the neigbors within a subcategory it's a little different.
Since an article can belong to more than one subcategory, subcategories are
stored in a list. If you have an article with subcategories like

``Category/Foo/Bar``

it will belong to both subcategory Foo, and Foo/Bar. Subcategory neighbors are
added to an article as ``next_article_in_subcategory#`` and
``prev_article_in_subcategory#`` where ``#`` is the level of subcategory. So using
the example from above, subcategory1 will be Foo, and subcategory2 Foo/Bar.
Therefor the usage with subcategories is:

.. code-block:: html+jinja


    {% if article.prev_article_in_subcategory1 %}


  • {{ article.prev_article_in_subcategory1.title }}


  • {% endif %}
    {% if article.next_article_in_subcategory1 %}


  • {{ article.next_article_in_subcategory1.title }}


  • {% endif %}


    {% if article.prev_article_in_subcategory2 %}


  • {{ article.prev_article_in_subcategory2.title }}


  • {% endif %}
    {% if article.next_article_in_subcategory2 %}


  • {{ article.next_article_in_subcategory2.title }}


  • {% endif %}