Browse Source

feat(shortcode): make in-page ToC collapsable

Useful for long pages with large ToCs and/or on small screens.

Also add `hide_on` and `show_on` options accepting Bootstrap responsive breakpoints.

Useful for setting `{{< toc hide_on="xl" >}}` in conjunction with Book layout which only shows right sidebar ToC on XL screens and above.
George Cushen 4 năm trước cách đây
mục cha
commit
468d327370
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      wowchemy/layouts/shortcodes/toc.html

+ 4 - 2
wowchemy/layouts/shortcodes/toc.html

@@ -1,2 +1,4 @@
-<h2>{{ i18n "table_of_contents" }}</h2>
-{{ $.Page.TableOfContents }}
+<details class="toc-inpage d-print-none {{with .Get "hide_on"}}d-{{.}}-none{{end}} {{with .Get "show_on"}}d-none d-{{.}}-block{{end}}" open>
+  <summary class="font-weight-bold">{{ i18n "table_of_contents" }}</summary>
+  {{ $.Page.TableOfContents }}
+</details>