|
7 | 7 |
|
8 | 8 | import pathe from '@flex-development/pathe' |
9 | 9 | import { |
| 10 | + NodeEnv, |
10 | 11 | cast, |
11 | 12 | flat, |
12 | 13 | get, |
| 14 | + includes, |
13 | 15 | join, |
14 | 16 | select, |
15 | 17 | template, |
@@ -60,7 +62,6 @@ const { |
60 | 62 | ALGOLIA_API_KEY = '', |
61 | 63 | ALGOLIA_APP_ID = '', |
62 | 64 | CI = 'false', |
63 | | - MEASUREMENT_ID, |
64 | 65 | NODE_ENV, |
65 | 66 | VERCEL_ENV = '', |
66 | 67 | VERIFICATION_ID = '' |
@@ -395,7 +396,19 @@ const config: UserConfig<ThemeConfig> = defineConfig<ThemeConfig>({ |
395 | 396 | }, |
396 | 397 | cleanUrls: vercel.cleanUrls, |
397 | 398 | 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 | + ], |
399 | 412 | ignoreDeadLinks: false, |
400 | 413 | lastUpdated: true, |
401 | 414 | markdown: MARKDOWN_OPTIONS, |
@@ -535,21 +548,7 @@ const config: UserConfig<ThemeConfig> = defineConfig<ThemeConfig>({ |
535 | 548 | ['meta', { content: 'vitepress', property: 'generator' }], |
536 | 549 |
|
537 | 550 | // 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' }] |
553 | 552 | ] |
554 | 553 | }, |
555 | 554 | /** |
@@ -585,7 +584,7 @@ const config: UserConfig<ThemeConfig> = defineConfig<ThemeConfig>({ |
585 | 584 | plugins: [tsconfigpaths({ projects: [pathe.resolve('tsconfig.json')] })], |
586 | 585 | server: { hmr: { overlay: false } } |
587 | 586 | }, |
588 | | - vue: { isProduction: [NODE_ENV, VERCEL_ENV].includes('production') } |
| 587 | + vue: { isProduction: includes([NODE_ENV, VERCEL_ENV], NodeEnv.PROD) } |
589 | 588 | }) |
590 | 589 |
|
591 | 590 | export default config |
0 commit comments