Merged in feat/current-route-groups (pull request #36)
feat: separate current and "new" web in route groups
This commit is contained in:
3
app/[lang]/(live)/content-page/page.tsx
Normal file
3
app/[lang]/(live)/content-page/page.tsx
Normal file
@@ -0,0 +1,3 @@
|
||||
export default async function ContentPage() {
|
||||
return null
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
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"
|
||||
@@ -33,42 +27,10 @@ export default function RootLayout({
|
||||
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"
|
||||
/> */}
|
||||
<AdobeScript />
|
||||
</head>
|
||||
<body>
|
||||
<LangPopup lang={params.lang} />
|
||||
<SkipToMainContent lang={params.lang} />
|
||||
{children}
|
||||
<Footer lang={params.lang} />
|
||||
<Script id="page-tracking">{`
|
||||
typeof _satellite !== "undefined" && _satellite.pageBottom();
|
||||
`}</Script>
|
||||
|
||||
@@ -4,10 +4,10 @@ import { request } from "@/lib/request"
|
||||
import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql"
|
||||
|
||||
import ContentPage from "@/components/Current/ContentPage"
|
||||
import Tracking from "../../Tracking"
|
||||
|
||||
import type { PageArgs, LangParams, UriParams } from "@/types/params"
|
||||
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
||||
import Tracking from "../../Tracking"
|
||||
|
||||
export default async function CurrentContentPage({
|
||||
params,
|
||||
79
app/[lang]/(live-current)/layout.tsx
Normal file
79
app/[lang]/(live-current)/layout.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
/* eslint-disable @next/next/no-css-tags */
|
||||
|
||||
import Footer from "@/components/Current/Footer"
|
||||
import LangPopup from "@/components/Current/LangPopup"
|
||||
import Script from "next/script"
|
||||
import SkipToMainContent from "@/components/SkipToMainContent"
|
||||
import AdobeScript from "../AdobeScript"
|
||||
|
||||
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>
|
||||
<link rel="stylesheet" href="/Static/css/core.css"/>
|
||||
<link rel="stylesheet" href="/Static/css/scandic.css"/>
|
||||
<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"
|
||||
/> */}
|
||||
<AdobeScript />
|
||||
</head>
|
||||
<body>
|
||||
<LangPopup lang={params.lang} />
|
||||
<SkipToMainContent lang={params.lang} />
|
||||
{children}
|
||||
<Footer lang={params.lang} />
|
||||
<Script id="page-tracking">{`
|
||||
typeof _satellite !== "undefined" && _satellite.pageBottom();
|
||||
`}</Script>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
8
app/[lang]/(live-current)/not-found.tsx
Normal file
8
app/[lang]/(live-current)/not-found.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<main>
|
||||
<h2>Not Found</h2>
|
||||
<p>Could not find requested resource</p>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -1,11 +1,3 @@
|
||||
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"
|
||||
import InitLivePreview from "@/components/Current/LivePreview"
|
||||
@@ -21,34 +13,9 @@ export default function RootLayout({
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||
return (
|
||||
<html lang={params.lang}>
|
||||
<head>
|
||||
<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"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<InitLivePreview />
|
||||
<LangPopup lang={params.lang} />
|
||||
<SkipToMainContent lang={params.lang} />
|
||||
{children}
|
||||
<Footer lang={params.lang} />
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
|
||||
@@ -1,45 +1,3 @@
|
||||
import { previewRequest } from "@/lib/previewRequest"
|
||||
import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql"
|
||||
|
||||
import type { PageArgs, LangParams, PreviewParams } from "@/types/params"
|
||||
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
||||
import ContentstackLivePreview from "@contentstack/live-preview-utils"
|
||||
import LoadingSpinner from "@/components/Current/LoadingSpinner"
|
||||
import ContentPage from "@/components/Current/ContentPage"
|
||||
|
||||
export default async function CurrentContentPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, PreviewParams>) {
|
||||
try {
|
||||
ContentstackLivePreview.setConfigFromParams(searchParams)
|
||||
|
||||
if (!searchParams.uri || !searchParams.live_preview) {
|
||||
return <LoadingSpinner />
|
||||
}
|
||||
|
||||
const response = await previewRequest<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")
|
||||
}
|
||||
|
||||
return (
|
||||
<ContentPage
|
||||
data={response.data}
|
||||
uri={searchParams.uri}
|
||||
lang={params.lang}
|
||||
/>
|
||||
)
|
||||
} catch (error) {
|
||||
// TODO: throw 500
|
||||
console.error(error)
|
||||
throw new Error("Something went wrong")
|
||||
}
|
||||
export default async function PreviewPage() {
|
||||
return null
|
||||
}
|
||||
|
||||
9
app/[lang]/(preview-current)/error.tsx
Normal file
9
app/[lang]/(preview-current)/error.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
"use client"
|
||||
|
||||
export default function Error({ error }: { error: Error }) {
|
||||
return (
|
||||
<div>
|
||||
<h2>Something went wrong!</h2>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
56
app/[lang]/(preview-current)/layout.tsx
Normal file
56
app/[lang]/(preview-current)/layout.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
/* eslint-disable @next/next/no-css-tags */
|
||||
|
||||
import Footer from "@/components/Current/Footer";
|
||||
import LangPopup from "@/components/Current/LangPopup";
|
||||
import Script from "next/script";
|
||||
import SkipToMainContent from "@/components/SkipToMainContent";
|
||||
import InitLivePreview from "@/components/Current/LivePreview";
|
||||
|
||||
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>
|
||||
<link rel="stylesheet" href="/Static/css/core.css"/>
|
||||
<link rel="stylesheet" href="/Static/css/scandic.css"/>
|
||||
<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"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<InitLivePreview />
|
||||
<LangPopup lang={params.lang} />
|
||||
<SkipToMainContent lang={params.lang} />
|
||||
{children}
|
||||
<Footer lang={params.lang} />
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
8
app/[lang]/(preview-current)/not-found.tsx
Normal file
8
app/[lang]/(preview-current)/not-found.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<main>
|
||||
<h2>Not Found</h2>
|
||||
<p>Could not find requested resource</p>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
45
app/[lang]/(preview-current)/preview-current/page.tsx
Normal file
45
app/[lang]/(preview-current)/preview-current/page.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { previewRequest } from "@/lib/previewRequest"
|
||||
import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql"
|
||||
|
||||
import type { PageArgs, LangParams, PreviewParams } from "@/types/params"
|
||||
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
||||
import ContentstackLivePreview from "@contentstack/live-preview-utils"
|
||||
import LoadingSpinner from "@/components/Current/LoadingSpinner"
|
||||
import ContentPage from "@/components/Current/ContentPage"
|
||||
|
||||
export default async function CurrentPreviewPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, PreviewParams>) {
|
||||
try {
|
||||
ContentstackLivePreview.setConfigFromParams(searchParams)
|
||||
|
||||
if (!searchParams.uri || !searchParams.live_preview) {
|
||||
return <LoadingSpinner />
|
||||
}
|
||||
|
||||
const response = await previewRequest<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")
|
||||
}
|
||||
|
||||
return (
|
||||
<ContentPage
|
||||
data={response.data}
|
||||
uri={searchParams.uri}
|
||||
lang={params.lang}
|
||||
/>
|
||||
)
|
||||
} catch (error) {
|
||||
// TODO: throw 500
|
||||
console.error(error)
|
||||
throw new Error("Something went wrong")
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,10 @@ export async function middleware(request: NextRequest) {
|
||||
searchParams.set("uri", pathNameWithoutLocale.replace("/preview", ""))
|
||||
|
||||
return NextResponse.rewrite(
|
||||
new URL(`/${locale}/preview?${searchParams.toString()}`, request.url)
|
||||
new URL(
|
||||
`/${locale}/preview-current?${searchParams.toString()}`,
|
||||
request.url
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user