fix: useTitle types (#2369)
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #2369
Co-authored-by: Dominik Pschenitschni <mail@celement.de>
Co-committed-by: Dominik Pschenitschni <mail@celement.de>
This commit is contained in:
Dominik Pschenitschni 2024-06-11 20:36:47 +00:00 committed by konrad
parent 97a11d2e12
commit 9fd17aca18

View File

@ -1,15 +1,15 @@
import {computed} from 'vue'
import type {Ref} from 'vue'
import {useTitle as useTitleVueUse, toRef} from '@vueuse/core'
import {useTitle as useTitleVueUse, toValue, type UseTitleOptions, type ReadonlyRefOrGetter, type MaybeRef, type MaybeRefOrGetter} from '@vueuse/core'
type UseTitleParameters = Parameters<typeof useTitleVueUse>
export function useTitle(...args: UseTitleParameters) {
const [newTitle, ...restArgs] = args
const pageTitle = toRef(newTitle) as Ref<string>
export function useTitle(
newTitle:
| ReadonlyRefOrGetter<string | null | undefined>
| MaybeRef<string | null | undefined>
| MaybeRefOrGetter<string | null | undefined> = null,
options?: UseTitleOptions,
) {
const pageTitle = computed(() => toValue(newTitle))
const completeTitle = computed(() =>
(typeof pageTitle.value === 'undefined' || pageTitle.value === '')
@ -17,5 +17,5 @@ export function useTitle(...args: UseTitleParameters) {
: `${pageTitle.value} | Vikunja`,
)
return useTitleVueUse(completeTitle, ...restArgs)
return useTitleVueUse(completeTitle, options)
}