diff --git a/package.json b/package.json index 1c53a25e..b2a8cd67 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "react-icons": "^5.3.0", "react-use": "^17.5.1", "sanity": "^3.54.0", - "sitemap": "^8.0.0" + "sitemap": "^8.0.0", + "react-error-boundary": "^3.1.4" // P4dcd }, "devDependencies": { "@ladle/react": "^4.1.0", diff --git a/src/app/RootLayout.tsx b/src/app/RootLayout.tsx deleted file mode 100644 index 504494af..00000000 --- a/src/app/RootLayout.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { groq } from "next-sanity"; -import { client } from "@/lib/sanity/client"; -import Header from "@/components/Layout/Header.component"; - -const navigationQuery = groq` - *[_type == "navigation"][0] { - title, - links[] { - title, - name, - hash, - href, - externalLink - } - } -`; - -export default async function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - const navigation = await client.fetch(navigationQuery); - - return ( - <> -
- {children} - - ); -} diff --git a/src/app/cv/page.tsx b/src/app/cv/page.tsx index 460efb6b..94357f3a 100644 --- a/src/app/cv/page.tsx +++ b/src/app/cv/page.tsx @@ -1,4 +1,3 @@ -import RootLayout from "../RootLayout"; import CVContent from "@/components/CV/CVContent.component"; import { client } from "@/lib/sanity/client"; @@ -15,8 +14,8 @@ export default async function CVPage() { const cvData = await client.fetch(cvQuery); return ( - +
- +
); } diff --git a/src/app/kontakt/page.tsx b/src/app/kontakt/page.tsx index a9284dd7..6b9be008 100644 --- a/src/app/kontakt/page.tsx +++ b/src/app/kontakt/page.tsx @@ -1,4 +1,3 @@ -import RootLayout from "../RootLayout"; import KontaktContent from "@/components/Kontakt/KontaktContent.component"; import { Metadata } from "next/types"; @@ -10,8 +9,8 @@ export const metadata: Metadata = { export default async function PostIndex() { return ( - +
- +
); } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 950e8d20..c56764d2 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,5 +1,6 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; +import { ErrorBoundary } from "react-error-boundary"; import "./globals.css"; import "./glitch.css"; @@ -13,6 +14,16 @@ export const metadata: Metadata = { description: "Daniel Fjeldstad | Frontend Web Utvikler | Portefølje", }; +function ErrorFallback({ error, resetErrorBoundary }: { error: Error, resetErrorBoundary: () => void }) { + return ( +
+

Something went wrong:

+
{error.message}
+ +
+ ); +} + export default function RootLayout({ children, }: Readonly<{ @@ -43,8 +54,10 @@ export default function RootLayout({ -
{children}
-