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; value='beta'>beta Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/examples/docs/public/make-scrollable-code-focusable.js (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-07-08Better response.arrayBuffer() handling in Node (#3860)Gravatar Matthew Phillips 8-3/+125
2022-07-08[ci] update lockfile (#3858)Gravatar Fred K. Bot 1-411/+437
2022-07-08Fix manual import (#3857)Gravatar Chris Williams 1-1/+1
2022-07-07[ci] formatGravatar bholmesdev 1-3/+3
2022-07-07Docs: add adapter heading for configuration docs (#3842)Gravatar Ben Holmes 2-4/+20
2022-07-07[ci] formatGravatar natemoo-re 2-3/+3
2022-07-07fix: lint failing on astro and some integrations (#3794)Gravatar Joaquín Sánchez 7-17/+18
2022-07-07update solid peer dependenciesGravatar Fred K. Schott 2-1/+6
2022-07-07update lockfile (#3828)Gravatar Fred K. Schott 3-7/+1
2022-07-07Improve JSX definitions (#3801)Gravatar Erika 2-477/+858
2022-07-07Fix slot attribute inside expressions (#3837)Gravatar Nate Moore 8-5/+89
2022-07-07[ci] formatGravatar FredKSchott 1-2/+1
2022-07-07detect package manager and improve types (#3847)Gravatar Fred K. Schott 7-44/+78
2022-07-07small create-astro wording changes (#3831)Gravatar Fred K. Schott 3-10/+15
2022-07-07Upgrade to pnpm@7.4.1, remove `patch-package` (#3747)Gravatar Nate Moore 6-127/+100
2022-07-07[ci] formatGravatar matthewp 1-1/+1
2022-07-07Allow importing Image component from @astrojs/image (#3848)Gravatar Matthew Phillips 7-6/+20
2022-07-06[ci] release (#3818)astro@1.0.0-beta.64@astrojs/telemetry@0.2.4@astrojs/node@0.1.4Gravatar Fred K. Bot 41-90/+90
2022-07-07[ci] formatGravatar bholmesdev 1-1/+1
2022-07-06Fix: Infer content type with charset in dev and prod (#3841)Gravatar Ben Holmes 4-3/+23
2022-07-06[ci] formatGravatar bholmesdev 1-2/+2
2022-07-06Fix `client:visible` directive in safari (#3839)Gravatar Ben Holmes 2-2/+20
2022-07-06[ci] formatGravatar matthewp 1-1/+1
2022-07-06Ensure that maybeRenderHead runs last (#3821)Gravatar Matthew Phillips 5-8/+67
2022-07-05Fix portfolio example to use lowercase srcset (#3829)Gravatar Matthew Phillips 1-1/+1
2022-07-05[ci] formatGravatar delucis 1-29/+29