Skip to content
Open
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
32 changes: 32 additions & 0 deletions _includes/toc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Table of contents

<div class="toc">
<ul id="toc-list"></ul>
</div>

<script>
document.addEventListener("DOMContentLoaded", function() {
const tocList = document.getElementById("toc-list");
const headings = document.querySelectorAll("main h2, article h2, .content h2");

headings.forEach((heading, index) => {
// Get the text, clean up spaces, and convert to lowercase
const headingText = heading.textContent.trim().toLowerCase();

// ⚠️ THIS LINE NOW EXCLUDES BOTH UNWANTED HEADINGS FROM THE LINKS
if (headingText === "table of contents" || headingText === "related content") return;

if (!heading.id) {
heading.id = "heading-" + index;
}

const li = document.createElement("li");
const a = document.createElement("a");
a.href = "#" + heading.id;
a.textContent = heading.textContent;

li.appendChild(a);
tocList.appendChild(li);
});
});
</script>
4 changes: 4 additions & 0 deletions style-guide/Gemfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'
gem 'nokogiri'
gem 'rack', '~> 2.2.4'
gem 'rspec'
Loading