-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
99 lines (85 loc) · 2.4 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<script setup lang="ts">
import { useHomeStore } from "~/segments/home/store";
const nuxtApp = useNuxtApp();
const homeStore = useHomeStore();
nuxtApp.hook("page:finish", () => {
window.scrollTo(0, 0); // emphasize scroll to top on route change
})
useState('userType', () => 'organization') // setting visitor as organization user
const { host } = useRequestURL();
if (host?.includes('servehub.io') || host?.includes('devweb') || host?.includes('localhost')) {
useHead({
script: [
{
src: '/js/chat.js',
type: 'text/javascript',
tagPosition: 'bodyClose'
}
]
})
}
useHead({
script: [
{
src: 'https://www.googletagmanager.com/gtag/js?id=G-6S59LVT28G',
async: true,
},
{
children: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-6S59LVT28G');
`,
},
{
children: `
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:1582803,hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`
}
]
});
const route = useRoute();
watch(() => route.path, async (val) => {
let metaData;
if (val === '/') metaData = await homeStore.fetchSEOData('/');
else {
const routeName = val.split('/');
metaData = await homeStore.fetchSEOData(routeName[1]);
}
assignPageMetaInfo(metaData)
}, { immediate: true });
function assignPageMetaInfo(metaData :MetaData) {
useSeoMeta({
title: () => metaData.metaTitle,
description: () => metaData.metaDescription,
ogTitle: () => metaData.metaTitle,
ogDescription: () => metaData.metaDescription,
ogUrl: () => metaData.structuredData?.url
})
useHead({
script: [
{
type: "application/ld+json",
textContent: JSON.stringify(metaData.structuredData)
}
],
})
}
</script>
<template>
<Html lang="en-US">
<VitePwaManifest />
<Body class="bg-gray-25 text-gray-900 antialiased transition-colors duration-300">
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</Body>
</Html>
</template>