File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { ThemeModeScript } from "flowbite-react" ;
2
2
import { Inter as InterFont } from "next/font/google" ;
3
- import { headers } from "next/headers " ;
4
- import type { Metadata , NextPage , Viewport } from "next/types " ;
5
- import type { FC , PropsWithChildren } from "react " ;
3
+ import type { Metadata , Viewport } from "next/types " ;
4
+ import type { PropsWithChildren } from "react " ;
5
+ import { FathomScript } from "~/components/fathom-script " ;
6
6
7
7
import "~/styles/globals.css" ;
8
8
@@ -54,25 +54,16 @@ export const viewport: Viewport = {
54
54
] ,
55
55
} ;
56
56
57
- const RootLayout : NextPage < PropsWithChildren > = ( { children } ) => {
58
- const pathname = headers ( ) . get ( "next-url" ) ;
59
- const isExamplesPage = pathname ?. startsWith ( "/examples/" ) ;
60
-
57
+ export default function RootLayout ( { children } : PropsWithChildren ) {
61
58
return (
62
59
< html lang = "en" className = { `${ interFont . variable } font-sans` } >
63
60
< head >
64
61
< ThemeModeScript />
65
62
</ head >
66
63
< body className = "bg-white text-gray-600 antialiased dark:bg-gray-900 dark:text-gray-400" >
67
64
{ children }
68
- { ! isExamplesPage && < FathomScript /> }
65
+ < FathomScript />
69
66
</ body >
70
67
</ html >
71
68
) ;
72
- } ;
73
-
74
- const FathomScript : FC = ( ) => {
75
- return < script data-site = "UXMSXUQI" defer src = "https://cdn.usefathom.com/script.js" /> ;
76
- } ;
77
-
78
- export default RootLayout ;
69
+ }
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import { usePathname } from "next/navigation" ;
4
+
5
+ export function FathomScript ( ) {
6
+ const pathname = usePathname ( ) ;
7
+ const isExamplesPage = pathname . startsWith ( "/examples/" ) ;
8
+
9
+ if ( isExamplesPage ) return null ;
10
+
11
+ return < script data-site = "UXMSXUQI" defer src = "https://cdn.usefathom.com/script.js" /> ;
12
+ }
You can’t perform that action at this time.
0 commit comments