Skip to content

Commit

Permalink
fix: try useEffect in meta
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Jul 11, 2024
1 parent 69a5b48 commit 7a1d3cc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/meta.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import Head from 'next/head'
import Analytics from './analytics'
import { useEffect } from 'react'
import { usePathname } from 'next/navigation'

const Meta = () => {
const pathname = usePathname()

useEffect(() => {
if (window.location.host === 'briefkastenhq.com') {
Swetrix.init(process.env.NEXT_PUBLIC_SWETRIX_PROJECT, {
apiURL: process.env.NEXT_PUBLIC_SWETRIX_API_HOST,
})
let url = pathname
Swetrix.trackPageview(url)
}
}, [pathname])

return (
<>
<Head>
Expand Down Expand Up @@ -46,7 +59,6 @@ const Meta = () => {
<meta name="twitter:image" content={''} />
<meta name="darkreader-lock" />
<title>Briefkasten</title>
<Analytics />
</Head>
</>
)
Expand Down

0 comments on commit 7a1d3cc

Please # to comment.