-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.ts
60 lines (52 loc) · 1.52 KB
/
module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {
addImportsDir,
addPlugin,
createResolver,
defineNuxtModule,
hasNuxtModule,
installModule,
} from '@nuxt/kit'
import { name, version } from '../package.json'
import type { Content } from '@remindgmbh/nuxt-typo3/models/typo3'
import { defu } from 'defu'
export const CONFIG_KEY = 'typo3Matomo'
export interface ModuleOptions {
cookie?: Content.Cookie['category']
domains: string
matomoUrl: string
siteId: number
}
export default defineNuxtModule<ModuleOptions>({
defaults: {
domains: '',
matomoUrl: '',
siteId: 0,
},
meta: {
configKey: CONFIG_KEY,
name,
version,
},
async setup(options, nuxt) {
const resolver = createResolver(import.meta.url)
nuxt.options.alias['@remindgmbh/nuxt-typo3-matomo'] =
resolver.resolve('runtime')
nuxt.options.runtimeConfig.public[CONFIG_KEY] = defu(
nuxt.options.runtimeConfig.public[CONFIG_KEY],
options,
)
addImportsDir(resolver.resolve('runtime/composables/**/*'))
if (nuxt.options._prepare) {
if (!hasNuxtModule('@remindgmbh/nuxt-typo3')) {
await installModule('@remindgmbh/nuxt-typo3')
}
if (!hasNuxtModule('@remindgmbh/nuxt-typo3-solr')) {
await installModule('@remindgmbh/nuxt-typo3-solr')
}
}
addPlugin({
mode: 'client',
src: resolver.resolve('./runtime/plugins/matomo'),
})
},
})