Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/_assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ function adjustToc() {
$('html, body').animate({ scrollTop: 0 }, 'fast');
})

// TODO: consider doing most of the HTML TOC manipulation statically (maybe requiring a jekyll-toc adaptor plugin)
// Bootstrap 4's ScrollSpy works only for .nav or .list-group,
// with items and link classes set too. Add the classes.
var toc = $(tocWrapper).find('ul.section-nav');
$(toc).addClass('nav');

var ul = $(toc).find('ul');
$(ul).addClass('nav');
var li = $(toc).find('.toc-entry');
$(li).addClass('nav-item');
$(li).find('a').addClass('nav-link');

$('body').scrollspy({ offset: 100, target: tocId });
}

Expand Down
6 changes: 6 additions & 0 deletions src/_includes/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
{% endif -%}

{% assign toc = content | toc_only -%}
{% if include.extendToc -%}
{% assign toc = toc | replace: '<ul>', '<ul class="nav">' %}
{% assign toc = toc | replace: '<ul class="section-nav">', '<ul class="section-nav nav">' %}
{% assign toc = toc | replace: 'class="toc-entry', 'class="toc-entry nav-item' %}
{% assign toc = toc | replace: '<a href="#', '<a class="nav-link" href="#' %}
{% endif -%}

{% comment %}
A TOC without <li> elements is empty. Only generate a TOC <div> for non-empty TOCs.
Expand Down
2 changes: 1 addition & 1 deletion src/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% include shared/sidenav-level-1.html nav=site.data.sidenav %}
</div>
{% if page.toc and layout.toc != false -%}
{% include toc.html kind="side" class="fixed-col col-xl-2 order-3" -%}
{% include toc.html kind="side" class="fixed-col col-xl-2 order-3" extendToc=true -%}
{% endif -%}
<main class="site-content {{main-col}}" role="main">
<div class="container">
Expand Down