1
|
|
|
import Theme from 'vitepress/theme' |
2
|
|
|
import {h, watch} from 'vue' |
3
|
|
|
import './custom.css' |
4
|
|
|
|
5
|
|
|
import NYSLogo from './NYSLogo.vue'; |
6
|
|
|
|
7
|
|
|
// Could also come from .env |
8
|
|
|
const GA_ID = 'UA-69117511-1'; |
9
|
|
|
|
10
|
|
|
export default { |
11
|
|
|
...Theme, |
12
|
|
|
Layout() { |
13
|
|
|
return h(Theme.Layout, null, { |
14
|
|
|
'aside-bottom': () => h(NYSLogo) |
15
|
|
|
} |
16
|
|
|
) |
17
|
|
|
}, |
18
|
|
|
enhanceApp: (ctx) => { |
19
|
|
|
// Google analytics integration |
20
|
|
|
if (import.meta.env.PROD && GA_ID && typeof window !== 'undefined') { |
21
|
|
|
(function (i, s, o, g, r, a, m) { |
22
|
|
|
i['GoogleAnalyticsObject'] = r |
23
|
|
|
i[r] = i[r] || function () { |
24
|
|
|
(i[r].q = i[r].q || []).push(arguments) |
25
|
|
|
} |
26
|
|
|
i[r].l = 1 * new Date() |
27
|
|
|
a = s.createElement(o) |
28
|
|
|
m = s.getElementsByTagName(o)[0] |
29
|
|
|
a.async = 1 |
30
|
|
|
a.src = g |
31
|
|
|
m.parentNode.insertBefore(a, m) |
32
|
|
|
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga') |
33
|
|
|
ga('create', GA_ID, 'auto') |
34
|
|
|
ga('set', 'anonymizeIp', true) |
35
|
|
|
// Send a page view any time the route changes |
36
|
|
|
watch(ctx.router.route, (newValue, oldValue) => { |
37
|
|
|
ga('set', 'page', newValue.path) |
38
|
|
|
ga('send', 'pageview') |
39
|
|
|
}) |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|