|
9 | 9 | } from "next-sanity"; |
10 | 10 | import { Inter } from "next/font/google"; |
11 | 11 | import { draftMode } from "next/headers"; |
12 | | -import { Suspense } from "react"; |
13 | 12 |
|
14 | 13 | import AlertBanner from "./alert-banner"; |
15 | 14 | import PortableText from "./portable-text"; |
@@ -56,60 +55,53 @@ const inter = Inter({ |
56 | 55 | display: "swap", |
57 | 56 | }); |
58 | 57 |
|
59 | | -async function Footer() { |
60 | | - const data = await sanityFetch({ query: settingsQuery }); |
61 | | - const footer = data?.footer || []; |
62 | | - |
63 | | - return ( |
64 | | - <footer className="bg-accent-1 border-accent-2 border-t"> |
65 | | - <div className="container mx-auto px-5"> |
66 | | - {footer.length > 0 ? ( |
67 | | - <PortableText |
68 | | - className="prose-sm text-pretty bottom-0 w-full max-w-none bg-white py-12 text-center md:py-20" |
69 | | - value={footer as PortableTextBlock[]} |
70 | | - /> |
71 | | - ) : ( |
72 | | - <div className="flex flex-col items-center py-28 lg:flex-row"> |
73 | | - <h3 className="mb-10 text-center text-4xl font-bold leading-tight tracking-tighter lg:mb-0 lg:w-1/2 lg:pr-4 lg:text-left lg:text-5xl"> |
74 | | - Built with Next.js. |
75 | | - </h3> |
76 | | - <div className="flex flex-col items-center justify-center lg:w-1/2 lg:flex-row lg:pl-4"> |
77 | | - <a |
78 | | - href="https://nextjs.org/docs" |
79 | | - className="mx-3 mb-6 border border-black bg-black py-3 px-12 font-bold text-white transition-colors duration-200 hover:bg-white hover:text-black lg:mb-0 lg:px-8" |
80 | | - > |
81 | | - Read Documentation |
82 | | - </a> |
83 | | - <a |
84 | | - href="https://github.com/vercel/next.js/tree/canary/examples/cms-sanity" |
85 | | - className="mx-3 font-bold hover:underline" |
86 | | - > |
87 | | - View on GitHub |
88 | | - </a> |
89 | | - </div> |
90 | | - </div> |
91 | | - )} |
92 | | - </div> |
93 | | - </footer> |
94 | | - ); |
95 | | -} |
96 | | - |
97 | | -export default function RootLayout({ |
| 58 | +export default async function RootLayout({ |
98 | 59 | children, |
99 | 60 | }: { |
100 | 61 | children: React.ReactNode; |
101 | 62 | }) { |
| 63 | + const data = await sanityFetch({ query: settingsQuery }); |
| 64 | + const footer = data?.footer || []; |
| 65 | + const { isEnabled: isDraftMode } = await draftMode(); |
| 66 | + |
102 | 67 | return ( |
103 | 68 | <html lang="en" className={`${inter.variable} bg-white text-black`}> |
104 | 69 | <body> |
105 | 70 | <section className="min-h-screen"> |
106 | | - {draftMode().isEnabled && <AlertBanner />} |
| 71 | + {isDraftMode && <AlertBanner />} |
107 | 72 | <main>{children}</main> |
108 | | - <Suspense> |
109 | | - <Footer /> |
110 | | - </Suspense> |
| 73 | + <footer className="bg-accent-1 border-accent-2 border-t"> |
| 74 | + <div className="container mx-auto px-5"> |
| 75 | + {footer.length > 0 ? ( |
| 76 | + <PortableText |
| 77 | + className="prose-sm text-pretty bottom-0 w-full max-w-none bg-white py-12 text-center md:py-20" |
| 78 | + value={footer as PortableTextBlock[]} |
| 79 | + /> |
| 80 | + ) : ( |
| 81 | + <div className="flex flex-col items-center py-28 lg:flex-row"> |
| 82 | + <h3 className="mb-10 text-center text-4xl font-bold leading-tight tracking-tighter lg:mb-0 lg:w-1/2 lg:pr-4 lg:text-left lg:text-5xl"> |
| 83 | + Built with Next.js. |
| 84 | + </h3> |
| 85 | + <div className="flex flex-col items-center justify-center lg:w-1/2 lg:flex-row lg:pl-4"> |
| 86 | + <a |
| 87 | + href="https://nextjs.org/docs" |
| 88 | + className="mx-3 mb-6 border border-black bg-black py-3 px-12 font-bold text-white transition-colors duration-200 hover:bg-white hover:text-black lg:mb-0 lg:px-8" |
| 89 | + > |
| 90 | + Read Documentation |
| 91 | + </a> |
| 92 | + <a |
| 93 | + href="https://github.com/vercel/next.js/tree/canary/examples/cms-sanity" |
| 94 | + className="mx-3 font-bold hover:underline" |
| 95 | + > |
| 96 | + View on GitHub |
| 97 | + </a> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + )} |
| 101 | + </div> |
| 102 | + </footer> |
111 | 103 | </section> |
112 | | - {draftMode().isEnabled && <VisualEditing />} |
| 104 | + {isDraftMode && <VisualEditing />} |
113 | 105 | <SpeedInsights /> |
114 | 106 | </body> |
115 | 107 | </html> |
|
0 commit comments