Skip to content

Commit

Permalink
✨ feat(ToC): implement setting hierarchy for ToC
Browse files Browse the repository at this point in the history
Related: #128 and #120
  • Loading branch information
welpo committed Sep 6, 2023
1 parent d6a5b1a commit 695e40b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions templates/macros/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"katex",
"quick_navigation_buttons",
"show_reading_time",
"show_remote_changes"
"show_remote_changes",
"toc",
] %}

<table>
Expand Down Expand Up @@ -95,7 +96,7 @@ <h3>TL;DR:</h3>
{% 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 %}

Expand Down
4 changes: 4 additions & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 695e40b

Please sign in to comment.