diff --git a/CHANGELOG.md b/CHANGELOG.md index 690e7e3a77e75da2024719cf2afa65a213a5b11f..b8fcfb0c3a45f1eff8fa5cb7d51c6a4e1c8ffde0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ modification of code. See updated `README.me`. * Added MathJax support for rendering Latex and math. * Added support for PseudocodeJS for rendering beautiful, standard, pseudocode. +* Table of contents will now render if frontmatter `toc` is set to `true`. ## 1.1.0 diff --git a/assets/css/main.css b/assets/css/main.css index 7d97cab511ae37da402c6b2f7e34b0965ffb3f3f..cdb955547f9098ec40d2527fc09f2e89474f5cea 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -629,3 +629,36 @@ section > .container > .row > .col { width: 100%; } } + +/* Styling for table of contents */ + +#TableOfContents { + border: 1px black solid; + display: inline-block; + padding-right: 40px; + padding-top: 5px; + padding-bottom: 5px; + background-color: floralwhite; + width: 400px; + margin-left: 40px; + margin-bottom: 10px; +} + +#TableOfContents ul { + padding-inline-start: 40px; +} + +#TableOfContents ul, +#TableOfContents ol { + padding-left: 40px; + margin-bottom: 10px; +} + +/* Adjusts links within the same page so as to not be covered by the header menu */ + +:target::before { + content: ""; + display: block; + height: calc(1em + var(--ifm-navbar-height)); /* fixed header height*/ + margin: calc(-1em * (1em + var(--ifm-navbar-height))) 0 0; /* negative fixed header height */ +} diff --git a/layouts/partials/articles_for_section.html b/layouts/partials/articles_for_section.html index 880187a3b8a5cf4a65a4c8a1c17c5daabeedd5f6..1531be9ce65722b8c44b13a337c328a7ef8a868f 100644 --- a/layouts/partials/articles_for_section.html +++ b/layouts/partials/articles_for_section.html @@ -3,6 +3,7 @@ {{ range $index, $element := $paginator.Pages }} <article class='post'> {{ partial "post_header_list.html" . }} + {{ partial "toc.html" . }} <section class='post-content'> {{.Content }} </section> diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html new file mode 100644 index 0000000000000000000000000000000000000000..64546ec06668af618037adea09819d77ace24364 --- /dev/null +++ b/layouts/partials/toc.html @@ -0,0 +1 @@ +{{ .TableOfContents }}