Add page titles (#4775)

* restructure template rendering

* add useTitle composable

* Split up render-string-template from getFieldsFromTemplate

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Nitwel
2021-03-31 16:53:57 +02:00
committed by GitHub
parent 8df659325c
commit 6f9b2cafcd
13 changed files with 81 additions and 50 deletions

View File

@@ -72,6 +72,7 @@ import NotificationsPreview from './components/notifications-preview/';
import NotificationDialogs from './components/notification-dialogs/';
import { useUserStore, useAppStore } from '@/stores';
import router from '@/router';
import useTitle from '@/composables/use-title';
export default defineComponent({
components: {
@@ -90,7 +91,8 @@ export default defineComponent({
default: null,
},
},
setup() {
setup(props) {
const { title } = toRefs(props);
const navOpen = ref(false);
const contentEl = ref<Element>();
const userStore = useUserStore();
@@ -113,20 +115,10 @@ export default defineComponent({
router.afterEach(async (to, from) => {
contentEl.value?.scrollTo({ top: 0 });
// await nextTick();
// const hash = to.hash;
// if (hash) {
// const linkedEl = document.querySelector(hash) as HTMLElement;
// if (linkedEl) {
// contentEl.value?.scrollTo({ top: linkedEl.offsetTop - 100, behavior: 'smooth' });
// }
// }
});
useTitle(title);
return {
navOpen,
contentEl,