Skip to content

Commit

Permalink
feat: refetch home page when click elk logo (#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost authored Jan 31, 2023
1 parent b62fd01 commit bd77d46
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ defineSlots<{
}>()
const { t } = useI18n()
const nuxtApp = useNuxtApp()
const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, $$(stream), eventType, preprocess)
nuxtApp.hook('elk-logo:click', () => {
update()
nuxtApp.$scrollToTop()
})
</script>

<template>
Expand Down
12 changes: 9 additions & 3 deletions components/nav/NavTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
const { env } = useBuildInfo()
const router = useRouter()
const back = ref<any>('')
const nuxtApp = useNuxtApp()
const onClickLogo = () => {
nuxtApp.hooks.callHook('elk-logo:click')
}
onMounted(() => {
back.value = router.options.history.state.back
})
Expand All @@ -11,16 +18,15 @@ router.afterEach(() => {
</script>

<template>
<!-- Use external to force refresh page and jump to top of timeline -->
<div flex justify-between>
<NuxtLink
flex items-end gap-4
py2 px-5
text-2xl
select-none
focus-visible:ring="2 current"
to="/"
external
to="/home"
@click.prevent="onClickLogo"
>
<NavLogo shrink-0 aspect="1/1" sm:h-8 xl:h-10 class="rtl-flip" />
<div hidden xl:block text-secondary>
Expand Down
6 changes: 6 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,9 @@ declare global {
}
}
}

declare module 'nuxt/dist/app' {
interface RuntimeNuxtHooks {
'elk-logo:click': () => void
}
}

0 comments on commit bd77d46

Please sign in to comment.