feat: init live preview sdk
This commit is contained in:
72
app/[lang]/(live)/current-content-page/page.tsx
Normal file
72
app/[lang]/(live)/current-content-page/page.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { request } from "@/lib/request";
|
||||
import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql";
|
||||
|
||||
import Aside from "@/components/Current/Aside"
|
||||
import Blocks from "@/components/Current/Blocks"
|
||||
import Header from "@/components/Current/Header"
|
||||
import Hero from "@/components/Current/Hero"
|
||||
import Preamble from "@/components/Current/Preamble"
|
||||
import Section from "@/components/Current/Section"
|
||||
import SubnavMobile from "@/components/Current/SubnavMobile"
|
||||
|
||||
import type { PageArgs, LangParams, UriParams } from "@/types/params"
|
||||
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
||||
|
||||
export default async function CurrentContentPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, UriParams>) {
|
||||
try {
|
||||
console.log({ searchParams });
|
||||
if (!searchParams.uri) {
|
||||
throw new Error("Bad URI")
|
||||
}
|
||||
|
||||
const response = await request<GetCurrentBlockPageData>(GetCurrentBlockPage, {
|
||||
locale: params.lang,
|
||||
url: searchParams.uri,
|
||||
})
|
||||
|
||||
if (!response.data?.all_current_blocks_page?.total) {
|
||||
console.log("#### DATA ####")
|
||||
console.log(response.data)
|
||||
console.log("SearchParams URI: ", searchParams.uri)
|
||||
throw new Error("Not found")
|
||||
}
|
||||
|
||||
const page = response.data.all_current_blocks_page.items[0]
|
||||
const images = page.hero?.imagesConnection
|
||||
const breadcrumbs = page.breadcrumbs.parentsConnection
|
||||
const parent = breadcrumbs.edges.at(-1)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header lang={params.lang} pathname={searchParams.uri} />
|
||||
{images?.totalCount ? <Hero images={images.edges} /> : null}
|
||||
<main
|
||||
className="main l-sections-wrapper"
|
||||
id="maincontent"
|
||||
role="main"
|
||||
>
|
||||
<input id="lbl-personalized-areas" name="lbl-personalized-areas" type="hidden" value="" />
|
||||
<SubnavMobile breadcrumbs={breadcrumbs} parent={parent} title={page.breadcrumbs.title} />
|
||||
<Preamble
|
||||
breadcrumbs={breadcrumbs}
|
||||
breadcrumbParent={parent}
|
||||
breadcrumbTitle={page.breadcrumbs.title}
|
||||
preamble={page.preamble}
|
||||
title={page.title}
|
||||
/>
|
||||
<Section>
|
||||
<Blocks blocks={page.blocks} />
|
||||
<Aside blocks={page.aside} />
|
||||
</Section>
|
||||
</main>
|
||||
</>
|
||||
)
|
||||
} catch (err) {
|
||||
return notFound()
|
||||
}
|
||||
}
|
||||
17
app/[lang]/(live)/current-content-page/template.tsx
Normal file
17
app/[lang]/(live)/current-content-page/template.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import Header from "@/components/Current/Header";
|
||||
|
||||
import type { LangParams, PageArgs, UriParams } from "@/types/params";
|
||||
|
||||
export default function CurrentContentpageTemplate({ children, params, searchParams }: React.PropsWithChildren<PageArgs<LangParams, UriParams>>) {
|
||||
// if (!searchParams.uri) {
|
||||
// throw new Error("Bad URI");
|
||||
// }
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <Header lang={params.lang} pathname={searchParams.uri} /> */}
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
73
app/[lang]/(live)/layout.tsx
Normal file
73
app/[lang]/(live)/layout.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import "../../core.css";
|
||||
import "../../scandic.css";
|
||||
|
||||
import Footer from "@/components/Current/Footer";
|
||||
import LangPopup from "@/components/Current/LangPopup";
|
||||
import Script from "next/script";
|
||||
import SkipToMainContent from "@/components/SkipToMainContent";
|
||||
|
||||
import type { Metadata } from "next";
|
||||
import type { LangParams, LayoutArgs } from "@/types/params";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
description: "New web",
|
||||
title: "Scandic Hotels New Web",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
params,
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||
return (
|
||||
<html lang={params.lang}>
|
||||
<head>
|
||||
<Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/cookie-bot.js?1705409331007"
|
||||
/>
|
||||
<Script
|
||||
data-blockingmode="auto"
|
||||
data-cbid="6d539de8-3e67-4f0f-a0df-8cef9070f712"
|
||||
data-culture="@cultureCode"
|
||||
id="Cookiebot"
|
||||
src="https://consent.cookiebot.com/uc.js"
|
||||
/>
|
||||
{/* <Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/head.js?85c84c9e24ae8da3e7af"
|
||||
/> */}
|
||||
<Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/inline.js?00133e5a37de35c51a5d"
|
||||
/>
|
||||
<Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/main.js?89d0030e1a04b3b46d0b"
|
||||
/>
|
||||
<Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/ng/polyfills.js?1705409330990"
|
||||
/>
|
||||
<Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/ng/runtime.js?1705409330990"
|
||||
/>
|
||||
<Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/ng/main.js?1705409330990"
|
||||
/>
|
||||
{/* <Script
|
||||
data-cookieconsent="ignore"
|
||||
src="/Static/dist/js/main-ng.js?336b801d6b38eff10884"
|
||||
strategy="lazyOnload"
|
||||
/> */}
|
||||
</head>
|
||||
<body>
|
||||
<LangPopup lang={params.lang} />
|
||||
<SkipToMainContent lang={params.lang} />
|
||||
{children}
|
||||
<Footer lang={params.lang} />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user