From 5b1fc089b0b65e7bbd0ba9c57e8361a3c0502671 Mon Sep 17 00:00:00 2001 From: Mark Boyd Date: Fri, 9 Aug 2024 17:33:51 -0400 Subject: [PATCH] render TOC conditionally --- _assets/css/styles.scss | 16 ++-------------- _config.yml | 2 +- _layouts/docs.html | 15 +++++++-------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/_assets/css/styles.scss b/_assets/css/styles.scss index f995c54a6..c7a4c5683 100644 --- a/_assets/css/styles.scss +++ b/_assets/css/styles.scss @@ -693,20 +693,8 @@ blockquote .source { background-color: color($theme-color-accent-warm-light); } -#table-of-contents ol#toc { - padding: 0; - list-style-position: inside; -} - -#table-of-contents h2 { - display: none; -} - #table-of-contents ol { - display: none; font-size: .9rem; -} - -#table-of-contents h2 + ol { - display: block; + padding: 0; + list-style-position: inside; } diff --git a/_config.yml b/_config.yml index 0c46feefd..ade665c3c 100644 --- a/_config.yml +++ b/_config.yml @@ -173,13 +173,13 @@ permalink: pretty markdown: kramdown url: "https://cloud.gov" plugins: + - jekyll-toc - jekyll-feed - jekyll-paginate-v2 - jekyll-redirect-from - jekyll-sitemap - jekyll-seo-tag - jekyll-last-modified-at - - jekyll-toc ############################################################ # Site configuration for the Jekyll 3 Pagination Gem diff --git a/_layouts/docs.html b/_layouts/docs.html index 562731b68..8df9de332 100644 --- a/_layouts/docs.html +++ b/_layouts/docs.html @@ -18,16 +18,15 @@

{{ page.title }}

- - {% if page.some_variable %} -

FOOBAR

- {% endif %} -
+ {% assign toc_content = content | toc_only | strip %} + {% if toc_content != '' %}

Table of Contents

- {{ content | toc_only }} -
- +
+ {{ toc_content }} +
+ {% endif %} + {{ content }}