Skip to content

Commit

Permalink
render TOC conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
markdboyd committed Aug 9, 2024
1 parent 270723a commit 5b1fc08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
16 changes: 2 additions & 14 deletions _assets/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions _layouts/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@

<div id="main-content" class="usa-layout-docs__main desktop:grid-col-8 usa-prose bg-white padding-y-8 padding-x-4">
<h1>{{ page.title }}</h1>

{% if page.some_variable %}
<h2>FOOBAR</h2>
{% endif %}

<div id="table-of-contents">
{% assign toc_content = content | toc_only | strip %}
{% if toc_content != '' %}
<h2>Table of Contents</h2>
{{ content | toc_only }}
</div>

<div id="table-of-contents">
{{ toc_content }}
</div>
{% endif %}

{{ content }}

<div class="grid-row">
Expand Down

0 comments on commit 5b1fc08

Please sign in to comment.