1
- /*
2
- *
3
- * 📦 [Module] NuxtModulePlausible
4
- *
5
- */
1
+ console . log ( '📦 [load:module] nuxt-module-plausible' )
6
2
7
3
// ///////////////////////////////////////////////////////////////////// Imports
8
4
// -----------------------------------------------------------------------------
9
- // ///////////////////////////////////////////////////////////////////// General
10
5
import Path from 'path'
6
+
7
+ import { defineNuxtModule , addPlugin } from 'nuxt/kit'
8
+
9
+ // ////////////////////////////////////////////////////////////////////// Config
10
+ // -----------------------------------------------------------------------------
11
+ const meta = {
12
+ name : '@undone-labs/nuxt-module-plausible' ,
13
+ configKey : 'nuxtModulePlausible' ,
14
+ compatibility : {
15
+ nuxt : '^3.0.0'
16
+ }
17
+ }
18
+
19
+ // /////////////////////////////////////////////////////////////////// Functions
20
+ // -----------------------------------------------------------------------------
11
21
// ///////////////////////////////////////////////////////////////////// Plugins
12
22
const plugins = [
13
23
{
@@ -17,21 +27,23 @@ const plugins = [
17
27
]
18
28
19
29
// ///////////////////////////////////////////////////////////// registerPlugins
20
- const registerPlugins = ( instance , next ) => {
21
- return new Promise ( ( next ) => {
30
+ const registerPlugins = ( ) => {
22
31
plugins . forEach ( ( plugin ) => {
23
- instance . addPlugin ( plugin )
32
+ addPlugin ( plugin )
33
+ console . log ( '🔌 [nuxt-module-plausible:plugin]' )
24
34
} )
25
- if ( next ) { return next ( ) }
26
- } )
27
35
}
28
36
29
- // ///////////////////////////////////////////////////////////////////// Liftoff
37
+ // /////////////////////////////////////////////////////////////////////// Setup
30
38
// -----------------------------------------------------------------------------
31
- export default async function ( ) {
32
- if ( this . options . plausible . include ) {
33
- await registerPlugins ( this , ( ) => {
34
- console . log ( `📦 [Module] Plausible` )
35
- } )
39
+ const setup = async ( _ , nuxt ) => {
40
+ if ( nuxt . options . plausible . include ) {
41
+ registerPlugins ( )
36
42
}
37
43
}
44
+ // ////////////////////////////////////////////////////////////////////// Export
45
+ // -----------------------------------------------------------------------------
46
+ export default defineNuxtModule ( {
47
+ meta,
48
+ setup
49
+ } )
0 commit comments