diff --git a/src/hooks/useLinks.hook.ts b/src/hooks/useLinks.hook.ts index f5a6b3d..f099965 100644 --- a/src/hooks/useLinks.hook.ts +++ b/src/hooks/useLinks.hook.ts @@ -19,6 +19,15 @@ export const useLinks = ( } if (href.startsWith("#")) { + event.preventDefault() + const id = href.slice(1) + const container = document.querySelector(`.${toValue(className)}`) + const heading = container?.querySelector(`#${CSS.escape(id)}`) + heading?.scrollIntoView({ + block: "start", + inline: "nearest", + behavior: "smooth" + }) return }