Pelican plugin to add next_article (newer) and/or prev_article (older) variables to article context
Project description
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
<ul>
{% if article.prev_article %}
<li>
<a href="{{ SITEURL }}/{{ article.prev_article.url}}">
{{ article.prev_article.title }}
</a>
</li>
{% endif %}
{% if article.next_article %}
<li>
<a href="{{ SITEURL }}/{{ article.next_article.url}}">
{{ article.next_article.title }}
</a>
</li>
{% endif %}
</ul>
<ul>
{% if article.prev_article_in_category %}
<li>
<a href="{{ SITEURL }}/{{ article.prev_article_in_category.url}}">
{{ article.prev_article_in_category.title }}
</a>
</li>
{% endif %}
{% if article.next_article_in_category %}
<li>
<a href="{{ SITEURL }}/{{ article.next_article_in_category.url}}">
{{ article.next_article_in_category.title }}
</a>
</li>
{% endif %}
</ul>
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:
<ul>
{% if article.prev_article_in_subcategory1 %}
<li>
<a href="{{ SITEURL }}/{{ article.prev_article_in_subcategory1.url}}">
{{ article.prev_article_in_subcategory1.title }}
</a>
</li>
{% endif %}
{% if article.next_article_in_subcategory1 %}
<li>
<a href="{{ SITEURL }}/{{ article.next_article_in_subcategory1.url}}">
{{ article.next_article_in_subcategory1.title }}
</a>
</li>
{% endif %}
</ul>
<ul>
{% if article.prev_article_in_subcategory2 %}
<li>
<a href="{{ SITEURL }}/{{ article.prev_article_in_subcategory2.url}}">
{{ article.prev_article_in_subcategory2.title }}
</a>
</li>
{% endif %}
{% if article.next_article_in_subcategory2 %}
<li>
<a href="{{ SITEURL }}/{{ article.next_article_in_subcategory2.url}}">
{{ article.next_article_in_subcategory2.title }}
</a>
</li>
{% endif %}
</ul>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pelican_neighbors-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 573bd5ecbfb127b9eab8c985004cefdd53e29a77ed98447d8116d6631c70f638 |
|
MD5 | aee32a31b80c901fef2ebebce80c9dfc |
|
BLAKE2b-256 | 769dc66a15ffd82cbc21d95af15421685b7e84f6e539a1db2224408240390157 |