Fix heading component
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m15s

This commit is contained in:
Ryan Freeman 2025-03-30 20:28:17 +01:00
parent e5eae13468
commit f4e920bff4

View File

@ -10,7 +10,7 @@ type HeadingProps = {
}
export function Heading({as: Component = 'h1', children = null}: HeadingProps) {
const ref = useRef<HTMLAnchorElement>(null);
const ref = useRef<HTMLAnchorElement>(null)
const headingText = children?.toString() || ''
useEffect(() => {
@ -20,9 +20,9 @@ export function Heading({as: Component = 'h1', children = null}: HeadingProps) {
}, [])
return (
<Component id={createSlug(headingText)} className="flex group">
<Component id={createSlug(headingText)} className="group">
{children}
<Link className="sr-only group-hover:not-sr-only !ml-1.5" href={`#${createSlug(headingText)}`} ref={ref}></Link>
<Link className="ml-1.5 invisible group-hover:visible" href={`#${createSlug(headingText)}`} ref={ref}></Link>
</Component>
)
}