Neighbor Articles: A Plugin for Pelican
Neighbors is a Pelican plugin that adds Next/Previous links to articles.
Installation
This plugin can be installed via:
python -m pip install pelican-neighbors
Usage
This plugin adds a couple of new variables to the article's context:
next_article(newer)prev_article(older)next_article_in_categoryprev_article_in_categorynext_article_in_subcategory#prev_article_in_subcategory#
Here is an example on how to add article navigation in your Jinja article.html
template:
<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>
More Categories plugin support
You can use the Neighbors plugin with the More Categories plugin.
Since an article can belong to more than one subcategory, subcategories are
stored in a list. If you have an article with subcategories like
foo/bar/baz, it will belong to both subcategory bar and bar/baz.
Subcategory neighbors are added to an article as next_article_in_subcategory#
and prev_article_in_subcategory#, where # is the level of subcategory.
Using the example above:
subcategory0isfoosubcategory1will befoo/barsubcategory2will befoo/bar/baz
Subcategory plugin support
You can use the Neighbors plugin in conjunction with the Subcategory plugin.
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
will be Foo/Bar.
Template Examples
The usage with subcategories from either the Subcategory plugin or the More Categories plugin 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>
Limitations
If an article has multiple categories, only the first category is considered.
Contributing
Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on existing issues.
To start contributing to this plugin, review the Contributing to Pelican documentation, beginning with the Contributing Code section.
Metadata
Release files for pelican-neighbors 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pelican-neighbors-1.2.0.tar.gz | 16.8 kB | Without provenance | Details for pelican-neighbors-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pelican_neighbors-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for pelican_neighbors-1.2.0-py3-none-any.whl |
Total release size: 33.6 kB
Release files / pelican-neighbors-1.2.0.tar.gz
| Download URL | pelican-neighbors-1.2.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cbeee08f4d2e135452c044924c3f8e5e39ff083dcfb7485e8eeafdab9d2e445
|
|
BLAKE2b-256 checksum How to use checksums |
31e1d5dfde3080c9ef32984da5001ecdec181d135013edeef2931532d7dcd855
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.7.10 Linux/5.4.0-1046-azure
|
Release files / pelican_neighbors-1.2.0-py3-none-any.whl
| Download URL | pelican_neighbors-1.2.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
963df1d27dd8b34ac7b85320e63184d3f4e396e4570a3d49f5911246387a35bb
|
|
BLAKE2b-256 checksum How to use checksums |
8dadf2ad5fa3c1d35681707cf809a4573dda85a67dac007c59ff9371dae87b29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.7.10 Linux/5.4.0-1046-azure
|
Security for pelican-neighbors 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.