From 695e40be706a57023f9a4b69f82fdb05db77b9ec Mon Sep 17 00:00:00 2001 From: welpo Date: Thu, 7 Sep 2023 01:59:28 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ToC):=20implement=20setting=20?= =?UTF-8?q?hierarchy=20for=20ToC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related: #128 and #120 --- config.toml | 4 ++++ templates/macros/content.html | 5 +++-- theme.toml | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config.toml b/config.toml index 71ad6c5..1d3cc70 100644 --- a/config.toml +++ b/config.toml @@ -204,6 +204,10 @@ katex = false # Can be set at page or section levels, following the hierarchy: page > section > config. See: https://github.com/welpo/tabi/pull/128 quick_navigation_buttons = false +# Add a Table of Contents to posts, right below the title and metadata. +# Can be set at page or section levels, following the hierarchy: page > section > config. See: https://github.com/welpo/tabi/pull/128 +toc = false + # Date format used when listing posts (main page, /blog section, tag posts list…) # Default is "6th July 2049" in English and "%d %B %Y" in other languages. long_date_format = "%d %B %Y" diff --git a/templates/macros/content.html b/templates/macros/content.html index 8ee3959..b37df89 100644 --- a/templates/macros/content.html +++ b/templates/macros/content.html @@ -19,7 +19,8 @@ "katex", "quick_navigation_buttons", "show_reading_time", - "show_remote_changes" + "show_remote_changes", + "toc", ] %} @@ -95,7 +96,7 @@ {% endif %} {# Optional table of contents below the header #} - {% if page.extra.toc | default(value=false) and page.toc %} + {% if page.toc and macros_settings::evaluate_setting_priority(setting="toc", page=page, default_global_value=false) == "true" %} {{ macros_toc::toc(page=page, header=true) }} {% endif %} diff --git a/theme.toml b/theme.toml index 35635ed..a92357d 100644 --- a/theme.toml +++ b/theme.toml @@ -89,6 +89,10 @@ katex = false # Can be set at page or section levels, following the hierarchy: page > section > config. See: https://github.com/welpo/tabi/pull/128 quick_navigation_buttons = false +# Add a Table of Contents to all posts, right below the title and metadata. +# Can be set at page or section levels, following the hierarchy: page > section > config. See: https://github.com/welpo/tabi/pull/128 +# toc = false + # Date format used when listing posts (main page, /blog section, tag posts list…) # Default is "6th July 2049" in English and "%d %B %Y" in other languages. # long_date_format = "%d %B %Y"