Skip to content

Commit a04227d

Browse files
committed
feat: makes imports more nuxt2 compatible
1 parent dada952 commit a04227d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

modules/nuxt-module-plausible/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ console.log('📦 [load:module] nuxt-module-plausible')
44
// -----------------------------------------------------------------------------
55
import Path from 'path'
66

7-
import { defineNuxtModule, addPlugin } from 'nuxt/kit'
7+
import { defineNuxtModule, addPlugin } from '@nuxt/kit'
88

99
// ////////////////////////////////////////////////////////////////////// Config
1010
// -----------------------------------------------------------------------------

modules/nuxt-module-plausible/plugin.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
// ///////////////////////////////////////////////////////////////////// Imports
22
// -----------------------------------------------------------------------------
3-
import { defineNuxtPlugin, useRuntimeConfig, useRouter } from '#imports'
4-
// import Config from '@/nuxt.config'
3+
import { defineNuxtPlugin } from '#imports'
54

65
// ////////////////////////////////////////////////////////////////////// Export
76
// -----------------------------------------------------------------------------
8-
export default defineNuxtPlugin(() => {
7+
export default defineNuxtPlugin((nuxtApp) => {
98

109
// Do not fire Plausible if not in production mode
1110
if (process.env.NODE_ENV !== 'production') {
1211
return
1312
}
1413

15-
const router = useRouter()
16-
const config = useRuntimeConfig()
14+
const router = nuxtApp.$router
15+
const config = nuxtApp.$config.public.siteUrl
1716
let isInitialPageLoad = true
1817

1918
router.afterEach((to) => {

0 commit comments

Comments
 (0)