1
0

feat: namespace settings archive script setup

This commit is contained in:
Dominik Pschenitschni
2022-09-13 17:33:56 +02:00
committed by Gitea
parent 221edb2086
commit ad6b335d41
3 changed files with 81 additions and 42 deletions

View File

@ -1,12 +1,21 @@
import { computed, watchEffect } from 'vue'
import type { ComputedGetter } from 'vue'
import { computed } from 'vue'
import type { Ref } from 'vue'
import { setTitle } from '@/helpers/setTitle'
import {useTitle as useTitleVueUse, resolveRef} from '@vueuse/core'
export function useTitle(titleGetter: ComputedGetter<string>) {
const titleRef = computed(titleGetter)
type UseTitleParameters = Parameters<typeof useTitleVueUse>
watchEffect(() => setTitle(titleRef.value))
export function useTitle(...args: UseTitleParameters) {
return titleRef
const [newTitle, ...restArgs] = args
const pageTitle = resolveRef(newTitle) as Ref<string>
const completeTitle = computed(() =>
(typeof pageTitle.value === 'undefined' || pageTitle.value === '')
? 'Vikunja'
: `${pageTitle.value} | Vikunja`,
)
return useTitleVueUse(completeTitle, ...restArgs)
}