From 98a647f8ca770cd078096e7bf993972ce8e86fee Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 30 Nov 2022 06:49:25 +0800 Subject: [PATCH] chore: avoid `useHead` naming conflicts --- composables/page-header.ts | 2 +- composables/useHead.ts | 7 ++++--- pages/@[account]/index.vue | 2 +- pages/blocks.vue | 2 +- pages/bookmarks.vue | 2 +- pages/conversations.vue | 2 +- pages/domain_blocks.vue | 2 +- pages/explore.vue | 2 +- pages/favourites.vue | 2 +- pages/home.vue | 2 +- pages/mutes.vue | 2 +- pages/notifications.vue | 2 +- pages/pinned.vue | 2 +- pages/public/index.vue | 2 +- pages/public/local.vue | 2 +- pages/tags/[tag].vue | 2 +- 16 files changed, 19 insertions(+), 18 deletions(-) diff --git a/composables/page-header.ts b/composables/page-header.ts index d742adfc..bb21b15c 100644 --- a/composables/page-header.ts +++ b/composables/page-header.ts @@ -5,7 +5,7 @@ const isPreview = window.location.hostname.includes('deploy-preview') export function usePageHeader() { const i18n = useI18n() - useHead({ + useHeadFixed({ htmlAttrs: { lang: () => i18n.locale.value, }, diff --git a/composables/useHead.ts b/composables/useHead.ts index df2697b8..e737add4 100644 --- a/composables/useHead.ts +++ b/composables/useHead.ts @@ -1,10 +1,11 @@ import type { ActiveHeadEntry, HeadEntryOptions, UseHeadInput } from '@vueuse/head' import type { HeadAugmentations } from '@nuxt/schema' -import { useHead as _useHead } from '#head' +import { useHead } from '#head' -export function useHead(input: UseHeadInput, options?: HeadEntryOptions): ActiveHeadEntry> | void { +// TODO: Workaround for Nuxt bug: https://github.com/elk-zone/elk/pull/199#issuecomment-1329771961 +export function useHeadFixed(input: UseHeadInput, options?: HeadEntryOptions): ActiveHeadEntry> | void { const deactivated = useDeactivated() - return _useHead(() => { + return useHead(() => { if (deactivated.value) return {} return resolveUnref(input) diff --git a/pages/@[account]/index.vue b/pages/@[account]/index.vue index aac1d6b2..c2315fa8 100644 --- a/pages/@[account]/index.vue +++ b/pages/@[account]/index.vue @@ -7,7 +7,7 @@ const { t } = useI18n() const { data: account, refresh } = $(await useAsyncData(() => fetchAccountByName(accountName).catch(() => null))) if (account) { - useHead({ + useHeadFixed({ title: () => `${getDisplayName(account)} (@${account.acct})`, }) } diff --git a/pages/blocks.vue b/pages/blocks.vue index c96cc266..e7702df8 100644 --- a/pages/blocks.vue +++ b/pages/blocks.vue @@ -5,7 +5,7 @@ definePageMeta({ const paginator = useMasto().blocks.getIterator() -useHead({ +useHeadFixed({ title: 'Blocked users', }) diff --git a/pages/bookmarks.vue b/pages/bookmarks.vue index 179ed8a9..d8ca0c13 100644 --- a/pages/bookmarks.vue +++ b/pages/bookmarks.vue @@ -7,7 +7,7 @@ const paginator = useMasto().bookmarks.getIterator() const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('nav_side.bookmarks'), }) diff --git a/pages/conversations.vue b/pages/conversations.vue index df65ec7e..7e456d25 100644 --- a/pages/conversations.vue +++ b/pages/conversations.vue @@ -7,7 +7,7 @@ const paginator = useMasto().conversations.getIterator() const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('nav_side.conversations'), }) diff --git a/pages/domain_blocks.vue b/pages/domain_blocks.vue index 5f7f64b7..23ed84cb 100644 --- a/pages/domain_blocks.vue +++ b/pages/domain_blocks.vue @@ -5,7 +5,7 @@ definePageMeta({ const paginator = useMasto().domainBlocks.getIterator() -useHead({ +useHeadFixed({ title: 'Blocked domains', }) diff --git a/pages/explore.vue b/pages/explore.vue index 396b99c1..e6ba7f13 100644 --- a/pages/explore.vue +++ b/pages/explore.vue @@ -3,7 +3,7 @@ const paginator = useMasto().trends.getStatuses() const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('nav_side.explore'), }) diff --git a/pages/favourites.vue b/pages/favourites.vue index 193720d9..340d133d 100644 --- a/pages/favourites.vue +++ b/pages/favourites.vue @@ -6,7 +6,7 @@ definePageMeta({ const paginator = useMasto().favourites.getIterator() const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('nav_side.favourites'), }) diff --git a/pages/home.vue b/pages/home.vue index 508424f8..1e466fa1 100644 --- a/pages/home.vue +++ b/pages/home.vue @@ -16,7 +16,7 @@ const stream = await useMasto().stream.streamUser() onBeforeUnmount(() => stream.disconnect()) const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('nav_side.home'), }) diff --git a/pages/mutes.vue b/pages/mutes.vue index 78be5b03..4bbfb9df 100644 --- a/pages/mutes.vue +++ b/pages/mutes.vue @@ -5,7 +5,7 @@ definePageMeta({ const paginator = useMasto().mutes.getIterator() -useHead({ +useHeadFixed({ title: 'Muted users', }) diff --git a/pages/notifications.vue b/pages/notifications.vue index f09b4769..d8ab90b6 100644 --- a/pages/notifications.vue +++ b/pages/notifications.vue @@ -14,7 +14,7 @@ const paginator = $computed(() => { return useMasto().notifications.getIterator(tab === 'All' ? undefined : { types: ['mention'] }) }) -useHead({ +useHeadFixed({ title: () => t('nav_side.notifications'), }) diff --git a/pages/pinned.vue b/pages/pinned.vue index 5e34924e..75b18006 100644 --- a/pages/pinned.vue +++ b/pages/pinned.vue @@ -6,7 +6,7 @@ definePageMeta({ const paginator = useMasto().accounts.getStatusesIterable(currentUser.value!.account.id, { pinned: true }) const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('account.pinned'), }) diff --git a/pages/public/index.vue b/pages/public/index.vue index 84df1619..22f6c860 100644 --- a/pages/public/index.vue +++ b/pages/public/index.vue @@ -5,7 +5,7 @@ onBeforeUnmount(() => stream.disconnect()) const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('title.federated_timeline'), }) diff --git a/pages/public/local.vue b/pages/public/local.vue index 93d09119..d66cbf01 100644 --- a/pages/public/local.vue +++ b/pages/public/local.vue @@ -5,7 +5,7 @@ onBeforeUnmount(() => stream.disconnect()) const { t } = useI18n() -useHead({ +useHeadFixed({ title: () => t('title.local_timeline'), }) diff --git a/pages/tags/[tag].vue b/pages/tags/[tag].vue index e58a18de..a8c7feee 100644 --- a/pages/tags/[tag].vue +++ b/pages/tags/[tag].vue @@ -9,7 +9,7 @@ const stream = await useMasto().stream.streamTagTimeline(tagName) onBeforeUnmount(() => stream.disconnect()) if (tag) { - useHead({ + useHeadFixed({ title: () => `#${tag.name}`, }) }