chore: update mdx-components

This commit is contained in:
2024-01-08 11:58:04 +01:00
parent 0b6ce93831
commit fb5383775b

View File

@@ -38,7 +38,7 @@ export const TableOfContents = ({ tocMap }: Props) => {
const headingsObserver = headingsObserverRef.current
setTimeout(() => {
document.querySelectorAll('article :is(h1,h2,h3)').forEach(h => headingsObserver.observe(h))
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
}, 100)
return () => {
@@ -53,13 +53,22 @@ export const TableOfContents = ({ tocMap }: Props) => {
// Disconnect and reconnect the observer to refresh it
headingsObserver.disconnect()
setTimeout(() => {
document.querySelectorAll('article :is(h1,h2,h3)').forEach(h => headingsObserver.observe(h))
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
}, 100)
}
}, [tocMap])
const onLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {
setCurrentHeading(e.currentTarget.getAttribute('href')!.replace('#', ''))
if (headingsObserverRef.current) {
const headingsObserver = headingsObserverRef.current
// Disconnect and reconnect the observer to refresh it
headingsObserver.disconnect()
setTimeout(() => {
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
}, 100)
}
}
return (