From 50baa4721f1658f5a3e2edbe33f59e99bdbcd692 Mon Sep 17 00:00:00 2001 From: thomasgross Date: Mon, 23 Dec 2024 17:15:35 +0100 Subject: [PATCH] feat: add dynamic page and display video paragraph --- app/[...path]/page.tsx | 23 ---------- app/[...slug]/page.tsx | 42 ++++++++++++++++++ app/layout.tsx | 2 +- app/page.tsx | 3 -- .../pages/basicPageLayout/BasicPageLayout.tsx | 17 ++++++++ .../ParagraphGoVideo/ParagraphGoVideo.tsx | 43 +++++++++++++++++++ components/paragraphs/ParagraphResolver.tsx | 29 +++++++++++++ .../paragraphErrorBoundary.tsx | 22 ++++++++++ components/videoPlayer/VideoPlayer.tsx | 36 ---------------- lib/graphql/generated/dpl-cms/graphql.tsx | 4 +- lib/graphql/queries/page.dpl-cms.graphql | 2 + package.json | 1 + styles/globals.css | 11 +++-- tailwind.config.ts | 2 + yarn.lock | 7 +++ 15 files changed, 177 insertions(+), 67 deletions(-) delete mode 100644 app/[...path]/page.tsx create mode 100644 app/[...slug]/page.tsx create mode 100644 components/pages/basicPageLayout/BasicPageLayout.tsx create mode 100644 components/paragraphs/ParagraphGoVideo/ParagraphGoVideo.tsx create mode 100644 components/paragraphs/ParagraphResolver.tsx create mode 100644 components/paragraphs/paragraphErrorBoundary/paragraphErrorBoundary.tsx delete mode 100644 components/videoPlayer/VideoPlayer.tsx diff --git a/app/[...path]/page.tsx b/app/[...path]/page.tsx deleted file mode 100644 index 3fecdcd..0000000 --- a/app/[...path]/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react" - -import { fetcher } from "@/lib/graphql/fetchers/dpl-cms.fetcher" -import { GetPageByPathDocument, GetPageByPathQuery } from "@/lib/graphql/generated/dpl-cms/graphql" - -async function page(props: { params: Promise<{ path: string[] }> }) { - const params = await props.params - - const { path } = params - - const data = await fetcher(GetPageByPathDocument, { - path: path.join("/"), - })() - - return ( -
- page -
{JSON.stringify(data, null, 2)}
-
- ) -} - -export default page diff --git a/app/[...slug]/page.tsx b/app/[...slug]/page.tsx new file mode 100644 index 0000000..a9e1386 --- /dev/null +++ b/app/[...slug]/page.tsx @@ -0,0 +1,42 @@ +import { notFound } from "next/navigation" +import React from "react" + +import BasicPageLayout from "@/components/pages/basicPageLayout/BasicPageLayout" +import { fetcher } from "@/lib/graphql/fetchers/dpl-cms.fetcher" +import { + GetPageByPathDocument, + GetPageByPathQuery, + NodeGoPage, +} from "@/lib/graphql/generated/dpl-cms/graphql" + +async function page(props: { params: Promise<{ slug: string[] }> }) { + const params = await props.params + + const { slug } = params + + const data = await fetcher(GetPageByPathDocument, { + path: slug.join("/"), + })() + + const routeType = data.route?.__typename + + if (routeType === "RouteRedirect") { + // TODO: implement redirect + return + } + + if (routeType === "RouteExternal") { + // TODO: implement external route redirect + return + } + + if (!routeType || !data?.route?.entity) { + return notFound() + } + + const pageData = data.route.entity + + return +} + +export default page diff --git a/app/layout.tsx b/app/layout.tsx index 7178ae0..a69817d 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -47,7 +47,7 @@ export default function RootLayout({
-
+
{children}