feat(WEB-38, WEB-9, WEB-19): add static page for sponsoring, add Header and add Footer
This commit is contained in:
52
app/[lang]/current-content-page/page.tsx
Normal file
52
app/[lang]/current-content-page/page.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import Header from "@/components/Current/Header";
|
||||
|
||||
import type { Params, SearchParams } from "@/types/params";
|
||||
|
||||
export default async function CurrentContentPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: Params<SearchParams>) {
|
||||
try {
|
||||
const filePath = path.join(
|
||||
process.cwd(),
|
||||
"mockCms",
|
||||
params.lang,
|
||||
searchParams.uri,
|
||||
"data.json"
|
||||
);
|
||||
|
||||
const data = await fs.readFile(filePath, { encoding: "utf-8" });
|
||||
|
||||
if (!data) {
|
||||
throw new Error("No data");
|
||||
}
|
||||
|
||||
const json = JSON.parse(data);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header lang={params.lang} pathname={searchParams.uri} />
|
||||
{json.hero ? (
|
||||
<div
|
||||
dangerouslySetInnerHTML={{ __html: json.hero }}
|
||||
className="hero-content-overlay"
|
||||
/>
|
||||
) : null}
|
||||
{json.content ? (
|
||||
<main
|
||||
className="main l-sections-wrapper"
|
||||
role="main"
|
||||
id="maincontent"
|
||||
dangerouslySetInnerHTML={{ __html: json.content }}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
} catch (err) {
|
||||
return notFound();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user