게시글 목차 스크롤 위치 보정 v1.5.13

This commit is contained in:
2026-05-27 11:34:09 +09:00
parent 602106ac9d
commit cb92b32f9c
8 changed files with 46 additions and 5 deletions

View File

@@ -71,6 +71,31 @@ const getRecommendedImageUrl = (item) => {
return thumbnailUrl || getExternalFaviconUrl(item?.url, 64)
}
/**
* 게시글 목차 링크를 부드럽게 이동한다.
* @param {MouseEvent} event - 클릭 이벤트
* @param {string} id - 이동할 제목 ID
* @returns {void}
*/
const scrollToTocItem = (event, id) => {
if (!import.meta.client) {
return
}
const target = document.getElementById(id)
if (!target) {
return
}
event.preventDefault()
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
})
window.history.replaceState(null, '', `${route.path}#${id}`)
}
/** 소개 영역 공개 여부 */
const showAboutSection = false
</script>
@@ -226,6 +251,7 @@ const showAboutSection = false
'pl-6 text-xs site-muted': item.level === 3
}"
:href="`#${item.id}`"
@click="scrollToTocItem($event, item.id)"
>
{{ item.text }}
</a>