All files / app layout.tsx

100% Statements 15/15
60% Branches 6/10
100% Functions 1/1
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128                                                      1x         1x         1x         1x                           3x 3x   1x 1x                 2x   1x   1x     1x       3x           3x                                                                                  
import "./globals.css";
 
import { JetBrains_Mono, Fraunces, Exo_2, Caveat  } from "next/font/google";
import { ThemeProvider } from "next-themes";
import { cn } from "@/lib/utils";
import { notFound } from "next/navigation";
import { Header, Footer } from "@/components/layout";
import { getGlobalPageData } from "@/data/loaders";
import ClientWidgets from "@/components/custom/ClientWidgets";
import 'vanilla-cookieconsent/dist/cookieconsent.css';
import CookieConsentComponent from '@/components/cookie/CookieConsent';
import ErrorPage from '@/components/custom/strapi-down-error-page';
import LoginButtonServer from "@/components/custom/LoginButtonServer";
 
// Font Configuration using next/font with CSS variables for Tailwind integration
/*
Prefered fonts:
- Sorts Mill Goudy
- IM Fell English  -> GREAT
- Fraunces
- Manrope  -> GREAT
- Caveat
- Google Sans Flex
- Sora
- Exo 2
- Expletus Sans 
*/
const fontSans = Exo_2 ({
  variable: "--font-sans",
  subsets: ["latin"],
});
 
const fontHeading = Fraunces({
  variable: "--font-heading",
  subsets: ["latin"],
});
 
const fontMono = JetBrains_Mono({
  variable: "--font-mono",
  subsets: ["latin"],
});
 
const fontSpecial = Caveat({
  variable: "--font-special",
  subsets: ["latin"],
});
 
 
 
export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  let data;
  
  try {
    data = await getGlobalPageData();
  } catch (error) {
    console.error("Error fetching global data, strapi is down", error);
    return (
      <html lang="en">
      <body className={cn("min-h-screen font-sans antialiased", fontSans.variable, fontHeading.variable, fontMono.variable, fontSpecial.variable)}>
        <ErrorPage /> 
      </body>
    </html>
    );
  }
  
  if (!data) notFound();
 
  const { topNav, footer, logo, logowide } = data.data;
 
  console.log("logowide:", data.data);
 
  // Ensure full image URL for Next.js Image component
  const logoSrc = logo?.url
  ? `${process.env.NEXT_PUBLIC_STRAPI_BASE_URL || "http://localhost:1337"}${logo.url}`
  : "";
 
  const logoWideSrc = logowide?.url
  ? `${process.env.NEXT_PUBLIC_STRAPI_BASE_URL || "http://localhost:1337"}${logowide.url}`
  : "";
 
 
 
  return (
    <html lang="en" suppressHydrationWarning>
      <body 
        className={cn(
          "min-h-screen",
          fontSans.variable,
          fontHeading.variable,
          fontMono.variable,
          fontSpecial.variable,
          "antialiased"
        )}
       >
 
       
        
        <ThemeProvider
          attribute="class"
          defaultTheme="system"
          enableSystem
          disableTransitionOnChange
        >
         
          <Header data={{ ...topNav, logoSrc }} /> {/* Pass logoSrc */}
          <LoginButtonServer />
 
          <main id="main-content" className="min-h-screen">
            {children}
          </main>
          
          <Footer data={{ ...footer, logoWideSrc }} />
          
          <CookieConsentComponent />
          
          <ClientWidgets />
          {/* if (pathname === "/") return <ClientWidgets />;  Only show on homepage */} 
          
        </ThemeProvider>
      </body>
    </html>
  );
}