// https://vitepress.dev/guide/custom-theme
import { h } from 'vue'
import type { Theme, EnhanceAppContext } from 'vitepress'
import DefaultTheme from 'vitepress/theme-without-fonts'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
import './scss/style.scss'
import matomo from '../matomo';

const matomoHost = import.meta.env.VITE_MATOMO_HOST;
const matomoSiteId = import.meta.env.VITE_MATOMO_SITE_ID;
console.log({matomo: typeof matomoHost !== 'undefined' && matomoHost})

export default {
  extends: DefaultTheme,
  Layout: () => {
    return h(DefaultTheme.Layout, null, {
      // https://vitepress.dev/guide/extending-default-theme#layout-slots
    })
  },
  enhanceApp({ app, router }: EnhanceAppContext) {
    enhanceAppWithTabs(app)
    if (typeof matomoHost !== 'undefined' && matomoHost) {
      matomo({
        router: router,
        siteID: matomoSiteId,
        trackerUrl: matomoHost
      })
    }
  }
} satisfies Theme
