Skip to content

Commit b7523d2

Browse files
committed
feat: add analytics + remove nuxt image
1 parent 633083c commit b7523d2

4 files changed

Lines changed: 35 additions & 112 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default defineNuxtPlugin({
2+
enforce: 'pre',
3+
env: { islands: false },
4+
setup() {
5+
if (import.meta.test || import.meta.dev) {
6+
return
7+
}
8+
9+
window.va = function (...params: unknown[]) {
10+
(window.vaq = window.vaq || []).push(params)
11+
}
12+
13+
useScript({
14+
'src': '/_v/script.js',
15+
'data-endpoint': '/_v',
16+
})
17+
},
18+
})
19+
20+
declare global {
21+
interface Window {
22+
va?: (...args: unknown[]) => void
23+
vaq?: unknown[][]
24+
}
25+
}

nuxt.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default defineNuxtConfig({
55
'@nuxtjs/html-validator',
66
'@nuxt/scripts',
77
'@nuxt/fonts',
8-
'@nuxt/image',
98
'nuxt-og-image',
109
'@nuxt/test-utils',
1110
'@vite-pwa/nuxt',
@@ -35,6 +34,10 @@ export default defineNuxtConfig({
3534
'/': { prerender: true },
3635
'/**': { isr: 60 },
3736
'/search': { isr: false, cache: false },
37+
'/_v/script.js': { proxy: 'https://npmx.dev/_vercel/insights/script.js' },
38+
'/_v/view': { proxy: 'https://npmx.dev/_vercel/insights/view' },
39+
'/_v/event': { proxy: 'https://npmx.dev/_vercel/insights/event' },
40+
'/_v/session': { proxy: 'https://npmx.dev/_vercel/insights/session' },
3841
},
3942

4043
future: {
@@ -48,6 +51,12 @@ export default defineNuxtConfig({
4851

4952
compatibilityDate: '2024-04-03',
5053

54+
nitro: {
55+
externals: {
56+
inline: ['isomorphic-dompurify'],
57+
},
58+
},
59+
5160
eslint: {
5261
config: {
5362
stylistic: true,

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"dependencies": {
2828
"@nuxt/eslint": "^1.12.1",
2929
"@nuxt/fonts": "^0.12.1",
30-
"@nuxt/image": "^2.0.0",
3130
"@nuxt/scripts": "^0.13.2",
3231
"@nuxtjs/html-validator": "^2.1.0",
3332
"nuxt": "https://pkg.pr.new/nuxt@8d4f9ba",

pnpm-lock.yaml

Lines changed: 0 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)