import plugins from core and restructure repo
This commit is contained in:
32
multi_part/Readme.md
Normal file
32
multi_part/Readme.md
Normal file
@@ -0,0 +1,32 @@
|
||||
Multi parts posts
|
||||
-----------------
|
||||
|
||||
The multi-part posts plugin allow you to write multi-part posts.
|
||||
|
||||
In order to mark posts as part of a multi-part post, use the `:parts:` metadata:
|
||||
|
||||
:parts: MY_AWESOME_MULTI_PART_POST
|
||||
|
||||
You can then use the `article.metadata.parts_articles` variable in your templates
|
||||
to display other parts of current post.
|
||||
|
||||
For example:
|
||||
|
||||
{% if article.metadata.parts_articles %}
|
||||
<ol class="parts">
|
||||
<li>Post parts</li>
|
||||
{% for part_article in article.metadata.parts_articles %}
|
||||
{% if part_article == article %}
|
||||
<li class="active">
|
||||
<a href='{{ SITEURL }}/{{ part_article.url }}'>{{ part_article.title }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<a href='{{ SITEURL }}/{{ part_article.url }}'>{{ part_article.title }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ol>
|
||||
{% endif %}
|
||||
1
multi_part/__init__.py
Normal file
1
multi_part/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .multi_part import *
|
||||
34
multi_part/multi_part.py
Normal file
34
multi_part/multi_part.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (c) FELD Boris <lothiraldan@gmail.com>
|
||||
|
||||
Multiple part support
|
||||
=====================
|
||||
|
||||
Create a navigation menu for multi-part related_posts
|
||||
"""
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from pelican import signals
|
||||
|
||||
|
||||
def aggregate_multi_part(generator):
|
||||
multi_part = defaultdict(list)
|
||||
|
||||
for article in generator.articles:
|
||||
if 'parts' in article.metadata:
|
||||
multi_part[article.metadata['parts']].append(article)
|
||||
|
||||
for part_id in multi_part:
|
||||
parts = multi_part[part_id]
|
||||
|
||||
# Sort by date
|
||||
parts.sort(key=lambda x: x.metadata['date'])
|
||||
|
||||
for article in parts:
|
||||
article.metadata['parts_articles'] = parts
|
||||
|
||||
|
||||
def register():
|
||||
signals.article_generator_finalized.connect(aggregate_multi_part)
|
||||
Reference in New Issue
Block a user