matrix-spec/layouts/partials/hooks/body-end.html
Kévin Commaille b1f66d1b71
Improve the JS script to highlight the current ToC entry (#1991)
The code relied on an IntersectionOberver, so the ToC was only updated when a heading was in the viewport.
It meant that if we jumped to a part of the text that has no heading, the ToC would still point to the old entry.

The new code looks for the correct heading when the view is scrolled so the correct entry is always selected.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-11-12 22:53:46 +00:00

11 lines
298 B
HTML

{{/*
This template is included at the end of each page's `<body>`.
We're using it here to highlight and scroll the ToC in the sidebar to match
the place we are at in the document.
*/}}
<script defer language="javascript" type="text/javascript" src="{{ "js/toc.js" | relURL }}"></script>