diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf18ed..e50915f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://codeberg.org/daudix/duckquill/compare/v5.3.2...main) +### Added + +- Add ability to enable inline table of contents in articles (#94 and #95). +- Add ability to make table of contents use numbered lists (#95). +- Add ability to open search by pressing the slash key. + ### Changed -- Allow opening search by pressing the slash key. - Focus search after opening it. +- Move quick navigation buttons to the top on mobile. - Return some `-webkit-` prefixes for wider compatibility. ## [5.3.2](https://codeberg.org/daudix/duckquill/compare/v5.3.1...v5.3.2) diff --git a/config.toml b/config.toml index a427882..e69049e 100644 --- a/config.toml +++ b/config.toml @@ -129,6 +129,21 @@ show_share_button = true # Note: This will make your page significantly heavier. # Instead, consider enabling it per page/section. # katex = true +# +# Whether to render table of contents on all pages. +# Will not be rendered if page doesn't have any headings. +# Can be set per page/section. +# toc = true +# +# Whether to render inline table of contents at the top of all pages, +# in addition to floating quick navigation buttons. +# Can be set per page/section. +# toc_inline = true +# +# Whether to use numbered (ordered) list for table of contents. +# Can be set per page/section. +# toc_ordered = true +# # Display outlines around all elements for debugging purposes # debug_layout = true @@ -206,12 +221,3 @@ show_qr = true # # Your GoatCounter username user = "duckquill" - -# Table of Contents (TOC) configs -[extra.toc] -# whether to render inline static TOC at the top of the articles or not -inline = true -# where to show the TOC as a pop-up button -popup = true -# Show numbered TOC -numbered = true diff --git a/content/blog/the-quill-of-duck/index.md b/content/blog/the-quill-of-duck/index.md index bed0a82..cc0b0d6 100644 --- a/content/blog/the-quill-of-duck/index.md +++ b/content/blog/the-quill-of-duck/index.md @@ -9,6 +9,8 @@ tags = ["Demo", "Test"] [extra] banner = "banner.webp" toc = true +toc_inline = true +toc_ordered = true trigger = "This page contains blackjack and hookers, and bad jokes such as this one." disclaimer = """ - All tricks in this page are performed by the lab boys, don't try this at home. diff --git a/sass/_article.scss b/sass/_article.scss index a2037d0..32e5fd6 100644 --- a/sass/_article.scss +++ b/sass/_article.scss @@ -180,6 +180,7 @@ overflow: auto; } + ol, ul { margin: 0; padding-inline-start: 0.75rem; diff --git a/sass/_footnotes-list.scss b/sass/_footnotes-list.scss index 3f57309..7b76bce 100644 --- a/sass/_footnotes-list.scss +++ b/sass/_footnotes-list.scss @@ -19,9 +19,21 @@ color: transparent; user-select: none; + :root[dir*="rtl"] & { + transform: scaleX(-1); + + &:active { + transform: scaleX(-1) var(--active); + } + } + &:hover { background-color: var(--accent-color); } + + &:active { + transform: var(--active); + } } a + a[href*="#fr-"], @@ -32,10 +44,6 @@ &:hover { opacity: 1; } - - &:active { - transform: var(--active); - } } li:target a[href*="#fr-"] { diff --git a/templates/article.html b/templates/article.html index f701c5a..2875856 100644 --- a/templates/article.html +++ b/templates/article.html @@ -5,11 +5,11 @@ {%- set date_locale = macros_translate::translate(key="date_locale", default="en_US", language_strings=language_strings) -%} {%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%} -{% if config.extra.toc.numbered %} - {% set list_element = "ol" %} -{% else %} - {% set list_element = "ul" %} -{% endif %} +{%- if page.extra.toc_ordered or section.extra.toc_ordered or config.extra.toc_ordered -%} + {%- set list_element = "ol" -%} +{%- else -%} + {%- set list_element = "ul" -%} +{%- endif -%}
{%- if page.extra.banner -%} @@ -77,28 +77,28 @@
- {%- if page.extra.toc and config.extra.toc.popup -%} + {%- if page.extra.toc and page.toc | length > 0 -%}
{{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}
- <{{list_element}}> + <{{ list_element }}> {%- for h1 in page.toc -%}
  • {{ h1.title }} {%- if h1.children -%} - <{{list_element}}> + <{{ list_element }}> {%- for h2 in h1.children -%}
  • {{ h2.title }}
  • {%- endfor -%} - + {%- endif -%} {%- endfor -%} - +
    @@ -114,26 +114,10 @@ {%- include "partials/statements.html" -%} - - {%- if page.extra.toc and config.extra.toc.inline-%} -

    {{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}

    - - <{{list_element}} role="list"> - {%- for h1 in page.toc -%} -
  • - {{ h1.title }} - {%- if h1.children -%} - <{{list_element}} role="list"> - {%- for h2 in h1.children -%} -
  • - {{ h2.title }} -
  • - {%- endfor -%} - - {%- endif -%} - - {%- endfor -%} - + {%- if page.extra.toc_inline -%} + {%- include "partials/toc.html" -%} + {%- elif config.extra.toc_inline -%} + {%- include "partials/toc.html" -%} {%- endif -%} {{ page.content | safe }} diff --git a/templates/partials/toc.html b/templates/partials/toc.html index 1d8cf0e..db918ee 100644 --- a/templates/partials/toc.html +++ b/templates/partials/toc.html @@ -1,37 +1,33 @@ -{%- if page.extra.toc -%} -

    {{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}

    - -{%- elif section.extra.toc -%} -

    {{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}

    - +{%- if page.extra.toc_ordered or section.extra.toc_ordered or config.extra.toc_ordered -%} + {%- set list_element = "ol" -%} +{%- else -%} + {%- set list_element = "ul" -%} +{%- endif -%} + +{%- if page.toc -%} + {%- set toc = page.toc -%} +{%- elif section.toc -%} + {%- set toc = section.toc -%} +{%- endif -%} + +{%- if page.extra.toc or section.extra.toc -%} + {%- if toc | length > 0 -%} +

    {{ macros_translate::translate(key="toc", default="Table of Contents", language_strings=language_strings) }}

    + <{{ list_element }}> + {%- for h1 in toc -%} +
  • + {{ h1.title }} + {%- if h1.children -%} + <{{ list_element }}> + {%- for h2 in h1.children -%} +
  • + {{ h2.title }} +
  • + {%- endfor -%} + + {%- endif -%} + + {%- endfor -%} + + {%- endif -%} {%- endif -%}