1
0
Fork 0

Watch route and set page title.

This commit is contained in:
Brian D 2024-11-17 22:21:56 -05:00
parent 8e7c20fde9
commit 0e28438740
2 changed files with 25 additions and 7 deletions

View file

@ -1,6 +1,15 @@
<script setup lang="ts">
import { RouterView } from 'vue-router'
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import OverlayBadge from 'primevue/overlaybadge';
const route = useRoute();
const page_title = ref();
watch(() => route.meta, (newVal, oldVal) => {
page_title.value = newVal.title;
})
</script>
<template>
@ -75,7 +84,7 @@ import OverlayBadge from 'primevue/overlaybadge';
>
<i class="pi pi-bars text-4xl" />
</a>
<span class="title">Page Title</span>
<span class="title">{{ page_title }}</span>
</div>
<a
v-styleclass="{

View file

@ -7,19 +7,28 @@ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView,
meta: {
title: 'Home',
},
name: 'home',
path: '/',
},
{
path: '/about',
name: 'about',
component: AboutView,
meta: {
title: 'About',
},
name: 'about',
path: '/about',
},
{
path: '/sticker',
name: 'sticker',
component: StickerView,
meta: {
title: 'Sticker',
},
name: 'sticker',
path: '/sticker',
},
],
})