mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-01-14 20:59:57 +01:00
Add smooth scroll
This commit is contained in:
@@ -56,6 +56,13 @@ async function handleLike() {
|
||||
await refresh()
|
||||
likeCookie.value = true
|
||||
}
|
||||
|
||||
function scrollToSection(id: string) {
|
||||
const element = document.getElementById(id)
|
||||
if (element) {
|
||||
element.scrollIntoView({ behavior: 'smooth' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -134,24 +141,12 @@ async function handleLike() {
|
||||
<UButton
|
||||
size="lg"
|
||||
:label="link.text"
|
||||
:to="`#${link.id}`"
|
||||
variant="link"
|
||||
color="neutral"
|
||||
:block="true"
|
||||
class="flex justify-start items-start"
|
||||
@click="scrollToSection(link.id)"
|
||||
/>
|
||||
<ol class="flex flex-col ml-2 list-decimal list-inside">
|
||||
<UButton
|
||||
v-for="child in link.children" :key="child.id"
|
||||
size="sm"
|
||||
:label="child.text"
|
||||
:to="`#${child.id}`"
|
||||
variant="link"
|
||||
color="neutral"
|
||||
:block="true"
|
||||
class="px-4 flex justify-start items-start"
|
||||
/>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -236,9 +231,17 @@ async function handleLike() {
|
||||
@apply no-underline;
|
||||
}
|
||||
|
||||
.prose img {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.katex-html {
|
||||
display: none;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
</style>
|
||||
|
||||
<i18n lang="json">
|
||||
|
||||
Reference in New Issue
Block a user