From b0581285337c7574afb6bce0ce33028cf42e96a3 Mon Sep 17 00:00:00 2001 From: Silvan Verhoeven Date: Mon, 29 Jul 2024 20:48:18 +0200 Subject: [PATCH] feat: hide toc button if toc empty --- .../core/templates/core/information_page.html | 1 + myhpi/core/templates/core/minutes.html | 5 +- myhpi/core/templates/core/sidebar.html | 48 ++++++++++--------- myhpi/core/templates/core/toc_button.html | 15 ++++++ myhpi/core/templatetags/core_extras.py | 5 ++ myhpi/templates/base.html | 8 ---- 6 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 myhpi/core/templates/core/toc_button.html diff --git a/myhpi/core/templates/core/information_page.html b/myhpi/core/templates/core/information_page.html index 7c11e5a6..dc34609a 100644 --- a/myhpi/core/templates/core/information_page.html +++ b/myhpi/core/templates/core/information_page.html @@ -5,6 +5,7 @@ {% block content %} {% with page.body|markdown as parsed_md %} + {% include "core/toc_button.html" with toc=parsed_md.1 %}

diff --git a/myhpi/core/templates/core/minutes.html b/myhpi/core/templates/core/minutes.html index 4a3f00c6..6380b5d4 100644 --- a/myhpi/core/templates/core/minutes.html +++ b/myhpi/core/templates/core/minutes.html @@ -6,8 +6,9 @@ {% load bootstrap_icons %} {% block content %} -
- {% with page.body|markdown as parsed_md %} + {% with page.body|markdown as parsed_md %} + {% include "core/toc_button.html" with toc=parsed_md.1 %} +

{{ page.title }} diff --git a/myhpi/core/templates/core/sidebar.html b/myhpi/core/templates/core/sidebar.html index 7e601742..0dc68b11 100644 --- a/myhpi/core/templates/core/sidebar.html +++ b/myhpi/core/templates/core/sidebar.html @@ -20,10 +20,12 @@

{% translate "Visibility" %}

+ {%if parsed_md.1|hasTocContent %} + {% endif %} {% if page.attachments.all %}
-