layout.tsx (2145B)
1 import React from "react"; 2 import Head from "next/head"; 3 import { Header } from "./header"; 4 import { Footer } from "./footer"; 5 import { Theme } from "./theme"; 6 import layoutData from "../../content/global/index.json"; 7 import { Global } from "../../tina/__generated__/types"; 8 9 10 11 export default function Layout({ 12 rawData = {}, 13 data = layoutData, 14 children, 15 }: { 16 rawData?: object; 17 data?: Omit<Global, "id" | "_sys" | "_values">; 18 children: React.ReactNode; 19 }) { 20 return ( 21 <> 22 <Head> 23 <title>Tina</title> 24 <meta name="viewport" content="initial-scale=1.0, width=device-width" /> 25 {data.theme.font === "nunito" && ( 26 <> 27 <link rel="preconnect" href="https://fonts.googleapis.com" /> 28 <link rel="preconnect" href="https://fonts.gstatic.com" /> 29 <link 30 href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,700;0,800;1,400;1,700;1,800&display=swap" 31 rel="stylesheet" 32 /> 33 </> 34 )} 35 {data.theme.font === "lato" && ( 36 <> 37 <link rel="preconnect" href="https://fonts.googleapis.com" /> 38 <link rel="preconnect" href="https://fonts.gstatic.com" /> 39 <link 40 href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&display=swap" 41 rel="stylesheet" 42 /> 43 </> 44 )} 45 </Head> 46 <Theme data={data?.theme}> 47 <div 48 className={`min-h-screen flex flex-col ${ 49 data.theme.font === "nunito" && "font-nunito" 50 } ${data.theme.font === "lato" && "font-lato"} ${ 51 data.theme.font === "sans" && "font-sans" 52 }`} 53 > 54 <Header data={data?.header} /> 55 <div className="flex-1 text-gray-800 bg-gradient-to-br from-white to-gray-50 dark:from-gray-900 dark:to-gray-1000 flex flex-col"> 56 {children} 57 </div> 58 <Footer 59 rawData={rawData} 60 data={data?.footer} 61 icon={data?.header.icon} 62 /> 63 </div> 64 </Theme> 65 </> 66 ); 67 }