diff options
author | 2022-02-07 13:39:53 -0500 | |
---|---|---|
committer | 2022-02-07 13:39:53 -0500 | |
commit | a911d14eabe4f4f9080b59b1c292818ea2ca6123 (patch) | |
tree | 529fdda395eedc122955fd2851954d61554869b4 /docs/src/components/RightSidebar/TableOfContents.tsx | |
parent | 2bc91543ceeb5f3dd45e201bf75d79f186e85141 (diff) | |
download | astro-a911d14eabe4f4f9080b59b1c292818ea2ca6123.tar.gz astro-a911d14eabe4f4f9080b59b1c292818ea2ca6123.tar.zst astro-a911d14eabe4f4f9080b59b1c292818ea2ca6123.zip |
Remove docs from monorepo (#2517)
* Remove docs from monorepo
* Update PULL_REQUEST_TEMPLATE.md
* Update relative doc references with links or todo
Diffstat (limited to 'docs/src/components/RightSidebar/TableOfContents.tsx')
-rw-r--r-- | docs/src/components/RightSidebar/TableOfContents.tsx | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/docs/src/components/RightSidebar/TableOfContents.tsx b/docs/src/components/RightSidebar/TableOfContents.tsx deleted file mode 100644 index 64ed93ba1..000000000 --- a/docs/src/components/RightSidebar/TableOfContents.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import type { FunctionalComponent } from 'preact'; -import { h, Fragment } from 'preact'; -import { useState, useEffect, useRef } from 'preact/hooks'; - -const TableOfContents: FunctionalComponent<{ headers: any[] }> = ({ - headers = [], -}) => { - const itemOffsets = useRef([]); - const [activeId, setActiveId] = useState<string>(undefined); - - useEffect(() => { - const getItemOffsets = () => { - const titles = document.querySelectorAll('article :is(h1, h2, h3, h4)'); - itemOffsets.current = Array.from(titles).map((title) => ({ - id: title.id, - topOffset: title.getBoundingClientRect().top + window.scrollY, - })); - }; - - getItemOffsets(); - window.addEventListener('resize', getItemOffsets); - - return () => { - window.removeEventListener('resize', getItemOffsets); - }; - }, []); - - return ( - <> - <h2 class="heading">On this page</h2> - <ul> - <li - class={`header-link depth-2 ${ - activeId === 'overview' ? 'active' : '' - }`.trim()} - > - <a href="#overview">Overview</a> - </li> - {headers - .filter(({ depth }) => depth > 1 && depth < 4) - .map((header) => ( - <li - class={`header-link depth-${header.depth} ${ - activeId === header.slug ? 'active' : '' - }`.trim()} - > - <a href={`#${header.slug}`}>{header.text}</a> - </li> - ))} - </ul> - </> - ); -}; - -export default TableOfContents; |