-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.ts
53 lines (45 loc) · 1.34 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
import {
addPlugin,
createResolver,
defineNuxtModule,
hasNuxtModule,
installModule,
} from '@nuxt/kit'
import { name, version } from '../package.json'
import { defu } from 'defu'
export const CONFIG_KEY = 'typo3Cookiebot'
export interface ModuleOptions {
// Cookiebot ID
// https://support.cookiebot.com/hc/en-us/articles/4405643234194-Your-CBID-or-Domain-group-ID-and-where-to-find-it
cbid: string
}
export default defineNuxtModule<ModuleOptions>({
defaults: {
cbid: '',
},
meta: {
configKey: CONFIG_KEY,
name,
version,
},
async setup(options, nuxt) {
const resolver = createResolver(import.meta.url)
nuxt.options.alias['@remindgmbh/nuxt-typo3-cookiebot'] =
resolver.resolve('runtime')
nuxt.options.runtimeConfig.public[CONFIG_KEY] = defu(
nuxt.options.runtimeConfig.public[CONFIG_KEY],
options,
)
nuxt.hook('prepare:types', (options) => {
options.references.push({
path: resolver.resolve('runtime/types/schema.d.ts'),
})
})
if (!hasNuxtModule('@remindgmbh/nuxt-typo3')) {
await installModule('@remindgmbh/nuxt-typo3')
}
addPlugin({
src: resolver.resolve('./runtime/plugins/cookiebot'),
})
},
})