import { CartProvider } from 'components/cart/cart-context'; import { Navbar } from 'components/layout/navbar'; import { WelcomeToast } from 'components/welcome-toast'; import { GeistSans } from 'geist/font/sans'; import { getCart } from 'lib/shopify'; import type { Cart } from 'lib/shopify/types'; import { ReactNode } from 'react'; import { Toaster } from 'sonner'; import './globals.css'; import { baseUrl } from 'lib/utils'; const { SITE_NAME } = process.env; export const metadata = { metadataBase: new URL(baseUrl), title: { default: SITE_NAME!, template: `%s | ${SITE_NAME}` }, robots: { follow: true, index: true } }; export default async function RootLayout({ children }: { children: ReactNode; }) { let cartPromise: Promise; try { // Don't await the fetch, pass the Promise to the context provider cartPromise = getCart(); } catch (e) { console.error('Failed to get cart during layout rendering (possibly build time for static page):', e); cartPromise = Promise.resolve(undefined); } return (
{children}
); }