Feat: toctree based on categories
This commit is contained in:
parent
d49fabf259
commit
548aecf9e3
@ -48,6 +48,9 @@ PLUGINS = [
|
|||||||
PATH_METADATA = '(?P<path_no_ext>.*)\..*'
|
PATH_METADATA = '(?P<path_no_ext>.*)\..*'
|
||||||
ARTICLE_URL = ARTICLE_SAVE_AS = PAGE_URL = PAGE_SAVE_AS = '{path_no_ext}.html'
|
ARTICLE_URL = ARTICLE_SAVE_AS = PAGE_URL = PAGE_SAVE_AS = '{path_no_ext}.html'
|
||||||
|
|
||||||
|
# USE_FOLDER_AS_CATEGORY = True
|
||||||
|
# DEFAULT_CATEGORY = "Autre"
|
||||||
|
|
||||||
# Readers
|
# Readers
|
||||||
READERS = {"html": None}
|
READERS = {"html": None}
|
||||||
# Everythings in french
|
# Everythings in french
|
||||||
@ -63,10 +66,13 @@ LOCALE = ("fr", "fr_FR.utf8")
|
|||||||
THEME = "./theme/"
|
THEME = "./theme/"
|
||||||
USE_GOOGLE_FONTS = False
|
USE_GOOGLE_FONTS = False
|
||||||
|
|
||||||
DISPLAY_PAGES_ON_SIDE = False
|
|
||||||
|
|
||||||
|
# Main menu on the top
|
||||||
MAIN_MENU = True
|
MAIN_MENU = True
|
||||||
DISPLAY_CATEGORIES_ON_MENU = False
|
DISPLAY_CATEGORIES_ON_MENU = False
|
||||||
|
|
||||||
|
# Sidebar
|
||||||
|
DISPLAY_PAGES_ON_SIDE = False
|
||||||
TOCTREE = True
|
TOCTREE = True
|
||||||
|
|
||||||
#SITELOGO = ""
|
#SITELOGO = ""
|
||||||
|
@ -86,7 +86,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
|
{% if TOCTREE %}
|
||||||
{% include "partial/toctree.html" %}
|
{% include "partial/toctree.html" %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if pages or LINKS%}
|
{% if pages or LINKS%}
|
||||||
<ul class="list">
|
<ul class="list">
|
||||||
@ -104,6 +106,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</nav>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
<main>
|
<main>
|
||||||
|
@ -1,34 +1,21 @@
|
|||||||
{% macro toc(root) %}
|
|
||||||
<ul class="toctree">
|
<ul class="toctree">
|
||||||
{% for child in root.children %}
|
{% for cat, articles in categories|sort %}
|
||||||
{% if child == article or child in article.parents%}
|
{% if article and article.category == cat %}
|
||||||
<li class="toctree-l1 current"><a href="{{ SITEURL }}/{{ child.url }}">{{ child.title }}</a>
|
<li class="toctree-l1 current"><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat | capitalize }}</a>
|
||||||
{% if child.children %}
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for c in child.children %}
|
{% for art in articles | sort(attribute="date") %}
|
||||||
{% if c == article %}
|
{% if article == art %}
|
||||||
<li class="toctree-l2 current"><span href="{{ SITEURL }}/{{ c.url }}">{{ c.title }}</span></li>
|
<li class="toctree-l2 current"><span>{{ art.title }}</span></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="toctree-l2"><a href="{{ SITEURL }}/{{ c.url }}">{{ c.title }}</a></li>
|
<li class="toctree-l2"><a href="{{ SITEURL }}/{{ art.url }}">{{ art.title }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
<li class="toctree-l1"><a href="{{ SITEURL }}/{{ child.url }}">{{ child.title }}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="toctree-l1"><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat | capitalize }}</a>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endmacro %}
|
|
||||||
|
|
||||||
|
|
||||||
{% if 'pelican-page-hierarchy' in PLUGINS and TOCTREE %}
|
|
||||||
{% if article and article.parents %}
|
|
||||||
{{ toc(article.parents[0]) }}
|
|
||||||
{% elif article and not article.parent %}
|
|
||||||
{{ toc(article) }}
|
|
||||||
{% else %}
|
|
||||||
<p> Le menu s'est perdu </p>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user