forked from Mirrors/elk
refactor: remove useHeadFixed
workaround (#1938)
Co-authored-by: Ayaka Rizumu <464388324@qq.com>
This commit is contained in:
parent
60a37e0bf8
commit
ab2881b9a2
40 changed files with 39 additions and 65 deletions
|
@ -20,7 +20,7 @@ const createdAt = useFormattedDateTime(status.createdAt)
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${getDisplayName(status.account)} ${t('common.in')} ${t('app_name')}: "${removeHTMLTags(status.content) || ''}"`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -12,7 +12,7 @@ export function setupPageHeader() {
|
|||
return acc
|
||||
}, {} as Record<string, Directions>)
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
htmlAttrs: {
|
||||
lang: () => locale.value,
|
||||
dir: () => localeMap[locale.value] ?? 'ltr',
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import type { ComponentInternalInstance } from 'vue'
|
||||
import { onActivated, onDeactivated, ref } from 'vue'
|
||||
import type { ActiveHeadEntry, HeadEntryOptions, UseHeadInput } from '@vueuse/head'
|
||||
import type { SchemaAugmentations } from '@unhead/schema'
|
||||
|
||||
export const isHydrated = ref(false)
|
||||
|
||||
|
@ -36,27 +34,3 @@ export function onReactivated(hook: Function, target?: ComponentInternalInstance
|
|||
}, target)
|
||||
onDeactivated(() => initial.value = false)
|
||||
}
|
||||
|
||||
// TODO: Workaround for Nuxt bug: https://github.com/elk-zone/elk/pull/199#issuecomment-1329771961
|
||||
export function useHeadFixed<T extends SchemaAugmentations>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void {
|
||||
const deactivated = useDeactivated()
|
||||
if (input && typeof input === 'object' && !('value' in input)) {
|
||||
const title = 'title' in input ? input.title : undefined
|
||||
if (process.server && title) {
|
||||
input.meta = input.meta || []
|
||||
if (Array.isArray(input.meta)) {
|
||||
input.meta.push(
|
||||
{ property: 'og:title', content: (typeof input.title === 'function' ? input.title() : input.title) as string },
|
||||
)
|
||||
}
|
||||
}
|
||||
else if (title) {
|
||||
(input as any).title = () => isHydrated.value ? typeof title === 'function' ? title() : title : ''
|
||||
}
|
||||
}
|
||||
return useHead(() => {
|
||||
if (deactivated.value)
|
||||
return {}
|
||||
return resolveUnref(input)
|
||||
}, options)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ const paginator = account ? useMastoClient().v1.accounts.listFollowers(account.i
|
|||
const isSelf = useSelfAccount(account)
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('account.followers')} | ${getDisplayName(account)} (@${account.acct})`,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ const paginator = account ? useMastoClient().v1.accounts.listFollowing(account.i
|
|||
const isSelf = useSelfAccount(account)
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('account.following')} | ${getDisplayName(account)} (@${account.acct})`,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ function reorderAndFilter(items: mastodon.v1.Status[]) {
|
|||
const paginator = useMastoClient().v1.accounts.listStatuses(account.id, { limit: 30, excludeReplies: true })
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('account.posts')} | ${getDisplayName(account)} (@${account.acct})`,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ const account = await fetchAccountByHandle(handle)
|
|||
const paginator = useMastoClient().v1.accounts.listStatuses(account.id, { onlyMedia: true, excludeReplies: false })
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.media')} | ${getDisplayName(account)} (@${account.acct})`,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ const account = await fetchAccountByHandle(handle)
|
|||
const paginator = useMastoClient().v1.accounts.listStatuses(account.id, { excludeReplies: false })
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.posts_with_replies')} | ${getDisplayName(account)} (@${account.acct})`,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ const paginator = useMastoClient().v1.trends.listStatuses()
|
|||
|
||||
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_POSTS_TIPS, false)
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.posts')} | ${t('nav.explore')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -7,7 +7,7 @@ const paginator = useMastoClient().v1.trends.listLinks()
|
|||
|
||||
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_NEWS_TIPS, false)
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.news')} | ${t('nav.explore')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -10,7 +10,7 @@ const paginator = client.v1.trends.listTags({
|
|||
|
||||
const hideTagsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_TAGS_TIPS, false)
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.hashtags')} | ${t('nav.explore')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -4,7 +4,7 @@ const { t } = useI18n()
|
|||
// limit: 20 is the default configuration of the official client
|
||||
const paginator = useMastoClient().v2.suggestions.list({ limit: 20 })
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.for_you')} | ${t('nav.explore')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -35,7 +35,7 @@ const { client } = $(useMasto())
|
|||
const { data: listInfo, refresh } = $(await useAsyncData(() => client.v1.lists.fetch(list), { default: () => shallowRef() }))
|
||||
|
||||
if (listInfo) {
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${listInfo.title} | ${route.fullPath.endsWith('/accounts') ? t('tab.accounts') : t('tab.posts')} | ${t('nav.lists')}`,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ const client = useMastoClient()
|
|||
|
||||
const paginator = client.v1.lists.list()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.lists'),
|
||||
})
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('title.federated_timeline'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('title.local_timeline'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -13,7 +13,7 @@ const paginator = client.v1.timelines.listHashtag(tagName)
|
|||
const stream = useStreaming(client => client.v1.stream.streamTagTimeline(tagName))
|
||||
|
||||
if (tag) {
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `#${tag.name}`,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.blocked_users'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.bookmarks'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.compose'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.conversations'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.blocked_domains'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.favourites'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -12,7 +12,7 @@ if (process.client && route.path === '/signin/callback')
|
|||
router.push('/home')
|
||||
|
||||
const { t } = useI18n()
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.home'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.muted_users'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.notifications_all')} | ${t('nav.notifications')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('tab.notifications_mention')} | ${t('nav.notifications')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('account.pinned'),
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => t('nav.settings'),
|
||||
})
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
const buildInfo = useBuildInfo()
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.about.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.interface.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ const { t, locale } = useI18n()
|
|||
|
||||
const translationStatus: ElkTranslationStatus = await import('~/elk-translation-status.json').then(m => m.default)
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.language.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
const status = computed(() => {
|
||||
|
|
|
@ -6,7 +6,7 @@ definePageMeta({
|
|||
const { t } = useI18n()
|
||||
const pwaEnabled = useAppConfig().pwaEnabled
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.notifications.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.notifications.notifications.label')} | ${t('settings.notifications.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -8,7 +8,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.notifications.push_notifications.label')} | ${t('settings.notifications.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.preferences.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.profile.appearance.title')} | ${t('nav.settings')}`,
|
||||
})
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.profile.featured_tags.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ definePageMeta({
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.profile.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@ import type { UserLogin } from '~/types'
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
useHead({
|
||||
title: () => `${t('settings.users.label')} | ${t('nav.settings')}`,
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue