Skip to content

Commit

Permalink
feat: add recent comment link with anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Aug 18, 2023
1 parent a1c4b51 commit ef0a517
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/components/Sidebar/src/RecentComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:key="comment.id"
>
<a
:href="comment.html_url"
:href="`${comment.html_url}#${comment.id}`"
class="flex flex-row justify-items-center items-stretch cursor-pointer hover:opacity-100"
>
<div class="flex justify-start items-start">
Expand All @@ -25,9 +25,11 @@
<div class="flex-1 text-xs">
<div class="text-xs mb-2 pt-1">
<span class="text-ob-secondary pr-2">
<a :href="comment.user.html_url">{{ comment.user.login }}</a>
<a class="font-bold" :href="comment.user.html_url">{{
comment.user.login
}}</a>
<b
class="text-ob bg-ob-deep-800 py-0.5 px-1.5 rounded-md"
class="ml-2 text-ob bg-ob-deep-800 py-0.5 px-1.5 rounded-md"
v-if="comment.is_admin"
>
{{ t('settings.admin-user') }}
Expand Down
13 changes: 12 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ const routes = [

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes
routes,
scrollBehavior(to, from, savedPosition) {
return new Promise(resolve => {
if (to.hash) {
setTimeout(() => {
resolve({ el: to.hash, behavior: 'smooth' })
}, 1500)
} else if (savedPosition) {
resolve(savedPosition)
}
})
}
})

export default router

0 comments on commit ef0a517

Please sign in to comment.