-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfaq.tsx
92 lines (82 loc) · 2.23 KB
/
faq.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import styled from "@emotion/styled";
import { CustomMarkdown } from "../src/Components/CustomMarkdown";
import { DefaultPageLayout } from "../src/Components/Layouts/DefaultPagelayout";
import Seo from "../src/Components/Seo";
import { H1 } from "../src/Components/core/Typography";
import {
FaqDocument,
FaqQueryVariables,
FaqQuery,
} from "../src/graphql/faq.generated";
import { urlQlient } from "../src/graphql/urql";
import { ParseQuery } from "../src/helpers/types";
import { ViewportSizes } from "../styles/theme";
type Page = ParseQuery<FaqQuery["page"]>;
export interface PageProps {
content: Page["contentCollection"]["items"];
seo: Page["seo"];
}
const ContentContainer = styled.div`
display: flex;
flex-direction: column;
gap: 1.5rem;
padding-top: 4rem;
width: 100vw;
max-width: 1440px;
padding-left: 1rem;
padding-right: 1rem;
@media (min-width: ${ViewportSizes.Phone}px) {
padding-left: 3rem;
padding-right: 3rem;
}
@media (min-width: ${ViewportSizes.TabletLandscape}px) {
}
@media (min-width: ${ViewportSizes.Desktop}px) {
gap: 32px;
}
`;
const StyledH1 = styled(H1)`
@media (max-width: ${ViewportSizes.Phone}px) {
font-size: 64px;
}
`;
export default function FAQ(props: PageProps) {
return (
<>
<Seo {...props.seo} />
<ContentContainer>
<StyledH1>Preguntas Frecuentes</StyledH1>
{props.content
.map((el) => {
if (el.__typename === "MarkdownBlock") {
return (
<CustomMarkdown key={el.sys.id}>
{el.markdownTextContent}
</CustomMarkdown>
);
}
return null;
})
.filter(Boolean)}
</ContentContainer>
</>
);
}
export async function getStaticProps() {
const queryResults = await urlQlient
.query<FaqQuery, FaqQueryVariables>(FaqDocument, {
locale: "es-CL",
isPreview: Boolean(process.env.NEXT_PUBLIC_CONTENTFUL_IS_PREVIEW),
id: "63a4MlorsHw5TRVyg2lQNU",
})
.toPromise();
const page = queryResults.data?.page as Page;
const props: PageProps = {
content: page.contentCollection.items,
seo: page?.seo || null,
};
return {
props,
};
}
FAQ.getLayout = DefaultPageLayout;