summaryrefslogtreecommitdiff
path: root/layouts/_partials/posts/toc.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/_partials/posts/toc.html')
-rw-r--r--layouts/_partials/posts/toc.html40
1 files changed, 0 insertions, 40 deletions
diff --git a/layouts/_partials/posts/toc.html b/layouts/_partials/posts/toc.html
index 0af63e4a..7a4a63cf 100644
--- a/layouts/_partials/posts/toc.html
+++ b/layouts/_partials/posts/toc.html
@@ -6,44 +6,4 @@
class="sticky top-12 text-size-sm 2xl:text-size-base px-8"
>{{ .TableOfContents }}</div>
</div>
-
-<script>
-document.addEventListener('DOMContentLoaded', () => {
- const toc = document.getElementById('toc');
- if (!toc) return;
-
- const headings = document.querySelectorAll('h2, h3');
- const observer = new IntersectionObserver(entries => {
- entries.forEach(entry => {
- if (!entry.isIntersecting) return;
-
- const id = entry.target.id;
- const tocLink = toc.querySelector(`a[href="#${id}"]`);
- if (!tocLink) return;
-
- const listItem = tocLink.parentElement;
- const isH2 = entry.target.tagName === 'H2';
-
- // Clear all active states when a new H2 is encountered
- if (isH2) {
- toc.querySelectorAll('li.active').forEach(el => el.classList.remove('active'));
- }
-
- // Set current item as active
- listItem.classList.add('active');
-
- // If this is an H3, find and activate its parent H2
- if (!isH2) {
- const parentH2Item = listItem.closest('ul').previousElementSibling?.closest('li');
- if (parentH2Item) parentH2Item.classList.add('active');
- }
- });
- }, {
- rootMargin: '0px 0px -50% 0px',
- threshold: 0.5
- });
-
- headings.forEach(heading => observer.observe(heading));
-});
-</script>
{{ end }}