This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/composables/useTitle.ts

21 lines
546 B
TypeScript
Raw Permalink Normal View History

2023-04-14 19:16:28 +00:00
import {computed} from 'vue'
import type {Ref} from 'vue'
2023-04-14 13:47:54 +00:00
import {useTitle as useTitleVueUse, toRef} from '@vueuse/core'
type UseTitleParameters = Parameters<typeof useTitleVueUse>
export function useTitle(...args: UseTitleParameters) {
const [newTitle, ...restArgs] = args
2023-04-14 19:16:28 +00:00
const pageTitle = toRef(newTitle) as Ref<string>
2023-04-14 19:16:28 +00:00
const completeTitle = computed(() =>
(typeof pageTitle.value === 'undefined' || pageTitle.value === '')
2023-04-14 19:16:28 +00:00
? 'Vikunja'
: `${pageTitle.value} | Vikunja`,
)
return useTitleVueUse(completeTitle, ...restArgs)
}