-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcfp.tsx
59 lines (52 loc) · 1.44 KB
/
cfp.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import dynamic from "next/dynamic";
import { Suspense } from "react";
import { DefaultPageLayout } from "../src/Components/Layouts/DefaultPagelayout";
import Seo from "../src/Components/Seo";
import {
CfpQueryDocument,
CfpQueryQuery,
CfpQueryQueryVariables,
} from "../src/graphql/cfp.generated";
import { urlQlient } from "../src/graphql/urql";
import { ParseQuery } from "../src/helpers/types";
const BannerCFP = dynamic(
async () => await import("../src/Components/Banner/CFP")
);
type Page = ParseQuery<CfpQueryQuery["page"]>;
export interface PageProps {
heroData: Page["heroBlock"];
seo: Page["seo"];
}
export default function OnSitePage(props: PageProps) {
return (
<>
<Seo {...props.seo} />
{Boolean(props.heroData) && (
<Suspense fallback={null}>
<BannerCFP {...props.heroData} />
</Suspense>
)}
</>
);
}
export async function getStaticProps() {
const queryResults = await urlQlient
.query<CfpQueryQuery, CfpQueryQueryVariables>(CfpQueryDocument, {
id: "1GDpX9fgkG15wZWOYFV4il",
locale: "es-CL",
isPreview: Boolean(process.env.NEXT_PUBLIC_CONTENTFUL_IS_PREVIEW),
})
.toPromise();
const page = queryResults.data?.page;
if (page === null || page === undefined) {
return { props: {} };
}
const props = {
heroData: page?.heroBlock ?? null,
seo: page?.seo ?? null,
};
return {
props,
};
}
OnSitePage.getLayout = DefaultPageLayout;