Skip to content

Commit

Permalink
feat(docs): add fathom
Browse files Browse the repository at this point in the history
  • Loading branch information
brankoconjic committed Dec 20, 2023
1 parent abaf55d commit b3e9b76
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@iconicicons/react": "^1.5.1",
"@radix-ui/react-scroll-area": "^1.0.5",
"clsx": "^2.0.0",
"fathom-client": "^3.6.0",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18",
Expand Down
3 changes: 3 additions & 0 deletions apps/docs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Sidebar } from "@/components/Sidebar";

import "@/styles/globals.css";

import Fathom from "@/components/Fathom";
import Header from "@/components/Header";

export const metadata: Metadata = {
Expand All @@ -27,6 +28,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
monoFont.variable
)}
>
<Fathom />

<div className="min-h-screen-dvh flex flex-col">
<Providers>
<Header />
Expand Down
32 changes: 32 additions & 0 deletions apps/docs/src/components/Fathom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Fathom.tsx
"use client";

import { Suspense, useEffect } from "react";
import { usePathname, useSearchParams } from "next/navigation";
import { load, trackPageview } from "fathom-client";

function TrackPageView() {
const pathname = usePathname();
const searchParams = useSearchParams();
useEffect(() => {
load("VDTVBMMX", {
includedDomains: ["lemonsqueezy.com"],
});
}, []);

useEffect(() => {
trackPageview();

// Record a pageview when route changes
}, [pathname, searchParams]);

return null;
}

export default function Fathom() {
return (
<Suspense fallback={null}>
<TrackPageView />
</Suspense>
);
}
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b3e9b76

Please sign in to comment.