Set title of page

Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
Benny Samir Hierl 2022-02-18 20:14:03 +01:00
parent 22550eafe0
commit 08f4f641fe
3 changed files with 18 additions and 2 deletions

View file

@ -3,6 +3,9 @@
"app-title": { "app-title": {
"text": "Wunschlisten" "text": "Wunschlisten"
}, },
"title": {
"text": "Wunschliste: {title}"
},
"loading": { "loading": {
"text": "Lade..." "text": "Lade..."
}, },

View file

@ -3,6 +3,9 @@
"app-title": { "app-title": {
"text": "Wishlists" "text": "Wishlists"
}, },
"title": {
"text": "Wishlist: {title}"
},
"loading": { "loading": {
"text": "Loading..." "text": "Loading..."
}, },

View file

@ -2,6 +2,7 @@
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { Wishlist, WishlistItem as WishlistItemType } from '@/types' import { Wishlist, WishlistItem as WishlistItemType } from '@/types'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { useTitle } from '@vueuse/core'
import { useWishlistStore, useModal, useEditMode } from '@/composables' import { useWishlistStore, useModal, useEditMode } from '@/composables'
import { import {
FormWishlist, FormWishlist,
@ -11,6 +12,7 @@ import {
} from '@/components' } from '@/components'
import { IconNoGift } from '../components/icons' import { IconNoGift } from '../components/icons'
import { useToast } from 'vue-toastification' import { useToast } from 'vue-toastification'
import { computed } from 'vue'
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
@ -18,7 +20,6 @@ const modal = useModal()
const { t } = useI18n() const { t } = useI18n()
const toast = useToast() const toast = useToast()
const { isActive: editModeIsActive } = useEditMode() const { isActive: editModeIsActive } = useEditMode()
const { const {
state, state,
fetch, fetch,
@ -30,7 +31,14 @@ const {
itemDelete, itemDelete,
filteredItems, filteredItems,
} = useWishlistStore() } = useWishlistStore()
await fetch(route.params.slug as string)
const title = computed(() => {
return state.value.title
? t('common.title.text', { title: state.value.title })
: t('common.loading.text')
})
useTitle(title)
const handleUpdateWishlist = async (wishlist: Wishlist): Promise<void> => { const handleUpdateWishlist = async (wishlist: Wishlist): Promise<void> => {
try { try {
@ -84,6 +92,8 @@ const handleDeleteItem = async (item: WishlistItemType): Promise<void> => {
itemDelete(item) itemDelete(item)
} }
} }
await fetch(route.params.slug as string)
</script> </script>
<template> <template>