Passed
Push — v1 ( 32f061...9764fd )
by Andrew
32:16 queued 26:31
created

docs/docs/.vitepress/theme/index.ts   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 43
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 33
mnd 1
bc 1
fnc 1
dl 0
loc 43
bpm 1
cpm 2
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.ts ➔ Layout 0 3 1
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