Files
portfolio/app/components/ClientProviders.tsx
denshooter 2c2c1f5d2d
All checks were successful
CI / CD / test-build (push) Successful in 10m16s
CI / CD / deploy-dev (push) Successful in 1m55s
CI / CD / deploy-production (push) Has been skipped
fix: SEO canonical URLs, LCP performance, remove unused dependencies
- Remove duplicate app/projects/ route (was causing 5xx and soft 404)
- Fix nginx: redirect www.dk0.dev → dk0.dev (non-www canonical)
- Fix not-found.tsx: locale-prefixed links, remove framer-motion dependency
- Add fetchPriority='high' and will-change to Hero LCP image
- Add preconnect hints for hardcover.app and cms.dk0.dev
- Reduce background blur from 100px to 80px (LCP rendering delay)
- Remove boneyard-js (~20 KiB), replace with custom Skeleton component
- Remove react-icons (~10 KiB), replace with inline SVGs
- Conditionally render mobile menu (saves ~20 DOM nodes)
- Add /books to sitemap
- Optimize image config with explicit deviceSizes/imageSizes
2026-04-17 09:50:31 +02:00

73 lines
1.9 KiB
TypeScript

"use client";
import React, { useEffect, useState } from "react";
import { usePathname } from "next/navigation";
import dynamic from "next/dynamic";
import { ToastProvider } from "@/components/Toast";
import ErrorBoundary from "@/components/ErrorBoundary";
import { ConsentProvider } from "./ConsentProvider";
import { ThemeProvider } from "./ThemeProvider";
const BackgroundBlobs = dynamic(
() => import("@/components/BackgroundBlobs").catch(() => ({ default: () => null })),
{ ssr: false, loading: () => null }
);
export default function ClientProviders({
children,
}: {
children: React.ReactNode;
}) {
const [mounted, setMounted] = useState(false);
const pathname = usePathname();
useEffect(() => {
setMounted(true);
}, [pathname]);
return (
<ErrorBoundary>
<ErrorBoundary>
<ConsentProvider>
<ThemeProvider>
<GatedProviders mounted={mounted}>
{children}
</GatedProviders>
</ThemeProvider>
</ConsentProvider>
</ErrorBoundary>
</ErrorBoundary>
);
}
function GatedProviders({
children,
mounted,
}: {
children: React.ReactNode;
mounted: boolean;
}) {
// Defer animated background blobs until after LCP
const [deferredReady, setDeferredReady] = useState(false);
useEffect(() => {
if (!mounted) return;
let id: ReturnType<typeof setTimeout> | number;
if (typeof requestIdleCallback !== "undefined") {
id = requestIdleCallback(() => setDeferredReady(true), { timeout: 5000 });
return () => cancelIdleCallback(id as number);
} else {
id = setTimeout(() => setDeferredReady(true), 200);
return () => clearTimeout(id);
}
}, [mounted]);
return (
<ErrorBoundary>
<ToastProvider>
{deferredReady && <BackgroundBlobs />}
<div className="relative z-10">{children}</div>
</ToastProvider>
</ErrorBoundary>
);
}