fix: useTitle types (#2369)
Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2369 Co-authored-by: Dominik Pschenitschni <mail@celement.de> Co-committed-by: Dominik Pschenitschni <mail@celement.de>
This commit is contained in:
parent
97a11d2e12
commit
9fd17aca18
@ -1,15 +1,15 @@
|
|||||||
import {computed} from 'vue'
|
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(
|
||||||
|
newTitle:
|
||||||
export function useTitle(...args: UseTitleParameters) {
|
| ReadonlyRefOrGetter<string | null | undefined>
|
||||||
|
| MaybeRef<string | null | undefined>
|
||||||
const [newTitle, ...restArgs] = args
|
| MaybeRefOrGetter<string | null | undefined> = null,
|
||||||
|
options?: UseTitleOptions,
|
||||||
const pageTitle = toRef(newTitle) as Ref<string>
|
) {
|
||||||
|
const pageTitle = computed(() => toValue(newTitle))
|
||||||
|
|
||||||
const completeTitle = computed(() =>
|
const completeTitle = computed(() =>
|
||||||
(typeof pageTitle.value === 'undefined' || pageTitle.value === '')
|
(typeof pageTitle.value === 'undefined' || pageTitle.value === '')
|
||||||
@ -17,5 +17,5 @@ export function useTitle(...args: UseTitleParameters) {
|
|||||||
: `${pageTitle.value} | Vikunja`,
|
: `${pageTitle.value} | Vikunja`,
|
||||||
)
|
)
|
||||||
|
|
||||||
return useTitleVueUse(completeTitle, ...restArgs)
|
return useTitleVueUse(completeTitle, options)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user