Skip to content

Commit 7c64268

Browse files
committed
docs: [site] configure vercel web analytics
- https://vercel.com/docs/concepts/analytics - https://vitepress.dev/reference/site-config#example-using-google-analytics Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent d56e322 commit 7c64268

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

docs/.vitepress/config.ts

+17-18
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
import pathe from '@flex-development/pathe'
99
import {
10+
NodeEnv,
1011
cast,
1112
flat,
1213
get,
14+
includes,
1315
join,
1416
select,
1517
template,
@@ -60,7 +62,6 @@ const {
6062
ALGOLIA_API_KEY = '',
6163
ALGOLIA_APP_ID = '',
6264
CI = 'false',
63-
MEASUREMENT_ID,
6465
NODE_ENV,
6566
VERCEL_ENV = '',
6667
VERIFICATION_ID = ''
@@ -395,7 +396,19 @@ const config: UserConfig<ThemeConfig> = defineConfig<ThemeConfig>({
395396
},
396397
cleanUrls: vercel.cleanUrls,
397398
description: pkg.description,
398-
head: [],
399+
head: [
400+
// vercel web analytics
401+
[
402+
'script',
403+
{
404+
defer: '',
405+
src:
406+
VERCEL_ENV === 'production'
407+
? '/_vercel/insights/script.js'
408+
: 'https://cdn.vercel-insights.com/v1/script.debug.js'
409+
}
410+
]
411+
],
399412
ignoreDeadLinks: false,
400413
lastUpdated: true,
401414
markdown: MARKDOWN_OPTIONS,
@@ -535,21 +548,7 @@ const config: UserConfig<ThemeConfig> = defineConfig<ThemeConfig>({
535548
['meta', { content: 'vitepress', property: 'generator' }],
536549

537550
// prevent duplicate content issues
538-
['link', { href: url, rel: 'canonical' }],
539-
540-
// google analytics
541-
[
542-
'script',
543-
{
544-
async: '',
545-
src: `https://www.googletagmanager.com/gtag/js?id=${MEASUREMENT_ID}`
546-
}
547-
],
548-
[
549-
'script',
550-
{},
551-
`window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}\ngtag('js',new Date());gtag('config','${MEASUREMENT_ID}')`
552-
]
551+
['link', { href: url, rel: 'canonical' }]
553552
]
554553
},
555554
/**
@@ -585,7 +584,7 @@ const config: UserConfig<ThemeConfig> = defineConfig<ThemeConfig>({
585584
plugins: [tsconfigpaths({ projects: [pathe.resolve('tsconfig.json')] })],
586585
server: { hmr: { overlay: false } }
587586
},
588-
vue: { isProduction: [NODE_ENV, VERCEL_ENV].includes('production') }
587+
vue: { isProduction: includes([NODE_ENV, VERCEL_ENV], NodeEnv.PROD) }
589588
})
590589

591590
export default config

0 commit comments

Comments
 (0)