Skip to content

Exclude analytics from examples page #1376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ThemeModeScript } from "flowbite-react";
import { Inter as InterFont } from "next/font/google";
import type { Metadata, NextPage, Viewport } from "next/types";
import type { FC, PropsWithChildren } from "react";
import type { Metadata, Viewport } from "next/types";
import type { PropsWithChildren } from "react";
import { FathomScript } from "~/components/fathom-script";

import "~/styles/globals.css";

Expand Down Expand Up @@ -53,7 +54,7 @@ export const viewport: Viewport = {
],
};

const RootLayout: NextPage<PropsWithChildren> = ({ children }) => {
export default function RootLayout({ children }: PropsWithChildren) {
return (
<html lang="en" className={`${interFont.variable} font-sans`}>
<head>
Expand All @@ -65,10 +66,4 @@ const RootLayout: NextPage<PropsWithChildren> = ({ children }) => {
</body>
</html>
);
};

const FathomScript: FC = () => {
return <script data-site="UXMSXUQI" defer src="https://cdn.usefathom.com/script.js" />;
};

export default RootLayout;
}
12 changes: 12 additions & 0 deletions apps/web/components/fathom-script.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use client";

import { usePathname } from "next/navigation";

export function FathomScript() {
const pathname = usePathname();
const isExamplesPage = pathname.startsWith("/examples/");

if (isExamplesPage) return null;

return <script data-site="UXMSXUQI" defer src="https://cdn.usefathom.com/script.js" />;
}