docs: redesign table of content (#12647)

* implement toc

* added to projects

* fixes and adapt for references

* added product frontmatter

* remove action menu from 404 pages
This commit is contained in:
Shahed Nasser
2025-05-30 16:55:36 +03:00
committed by GitHub
parent 490bd7647f
commit 009d00f27d
293 changed files with 1975 additions and 506 deletions
@@ -130,6 +130,29 @@ export const useActiveOnScroll = ({
? scrollableElement.scrollHeight / 2
: 0
if (scrollableElement?.scrollTop === 0) {
// set the first heading as active if the scrollable element is at the top
setActiveItemId(
items.length && useDefaultIfNoActive ? items[0].heading.id : ""
)
return
} else if (
scrollableElement?.scrollTop + scrollableElement?.clientHeight >=
scrollableElement?.scrollHeight
) {
// set the last heading as active if the scrollable element is at the bottom
let lastHeading = items[items.length - 1]
while (lastHeading?.children?.length) {
lastHeading = lastHeading.children[lastHeading.children.length - 1]
}
setActiveItemId(
lastHeading && useDefaultIfNoActive ? lastHeading.heading.id : ""
)
return
}
headings?.forEach((heading) => {
if (heading.id === hash) {
selectedHeadingByHash = heading as HTMLHeadingElement