Skip to content

Commit dc5f8b6

Browse files
committed
#3414 webpage: fix dev rendering issue
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 886e827 commit dc5f8b6

File tree

2 files changed

+44
-54
lines changed

2 files changed

+44
-54
lines changed

webpage/src/.vuepress/client.ts

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ import * as components from 'vuetify/components'
44
import * as directives from 'vuetify/directives'
55
import 'vuetify/styles'
66

7+
// Matomo type declaration
8+
declare global {
9+
interface Window {
10+
_paq: any[]
11+
}
12+
}
13+
714
// Import custom components
815
import Poll from './components/Poll.vue'
916
import BlogDate from './components/BlogDate.vue'
1017
import BlogIndex from './components/BlogIndex.vue'
1118
import ProfileCard from './components/ProfileCard.vue'
1219

13-
// Import Matomo analytics (replaces vuepress-plugin-matomo)
14-
import { initMatomo } from './utils/matomo.js'
15-
1620
export default defineClientConfig({
1721
enhance({ app, router, siteData }) {
1822
// Create Vuetify instance
@@ -34,7 +38,43 @@ export default defineClientConfig({
3438
app.component('ProfileCard', ProfileCard)
3539

3640
// Initialize Matomo Analytics (replaces vuepress-plugin-matomo)
37-
initMatomo(router)
41+
// Only run in browser environment
42+
if (typeof window !== 'undefined') {
43+
// Configuration
44+
const matomoConfig = {
45+
siteId: 7,
46+
trackerUrl: 'https://p.bekerle.com/',
47+
trackerJsFile: 'matomo.js',
48+
}
49+
50+
// Initialize Matomo
51+
window._paq = window._paq || []
52+
window._paq.push(['trackPageView'])
53+
window._paq.push(['enableLinkTracking'])
54+
55+
// Load Matomo script
56+
;(function () {
57+
const u = matomoConfig.trackerUrl
58+
window._paq.push(['setTrackerUrl', u + 'matomo.php'])
59+
window._paq.push(['setSiteId', matomoConfig.siteId.toString()])
60+
61+
const d = document
62+
const g = d.createElement('script')
63+
const s = d.getElementsByTagName('script')[0]
64+
g.async = true
65+
g.src = u + matomoConfig.trackerJsFile
66+
s.parentNode.insertBefore(g, s)
67+
})()
68+
69+
// Track page changes on route navigation (SPA support)
70+
router.afterEach((to) => {
71+
if (window._paq) {
72+
window._paq.push(['setCustomUrl', window.location.href])
73+
window._paq.push(['setDocumentTitle', document.title])
74+
window._paq.push(['trackPageView'])
75+
}
76+
})
77+
}
3878
},
3979
setup() {},
4080
rootComponents: [],

webpage/src/.vuepress/utils/matomo.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)