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(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 ( <>

On this page

); }; export default TableOfContents; e7bc9&follow=1'>commitdiff
path: root/vendor/golang.org/x/net/README.md (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2018-01-29Add flag to enable debug loggingGravatar Rogier Lommers 2-7/+64
2018-01-25Improve unread counter updatesGravatar Mahendra Kalkura 1-6/+35