-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfront-page.js
74 lines (69 loc) · 1.78 KB
/
front-page.js
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
import { useQuery, gql } from '@apollo/client';
import * as MENUS from '../constants/menus';
import { BlogInfoFragment } from '../fragments/GeneralSettings';
import {
Header,
Footer,
Main,
Container,
NavigationMenu,
Hero,
SEO,
} from '../components';
export default function Component() {
const { data } = useQuery(Component.query, {
variables: Component.variables(),
});
const { title: siteTitle, description: siteDescription } =
data?.generalSettings;
const primaryMenu = data?.headerMenuItems?.nodes ?? [];
const footerMenu = data?.footerMenuItems?.nodes ?? [];
return (
<>
<SEO title={siteTitle} description={siteDescription} />
<Header
title={siteTitle}
description={siteDescription}
menuItems={primaryMenu}
/>
<Main>
<Container>
<Hero title={'Front Page'} />
<div className="text-center">
<p>This page is utilizing the "front-page" WordPress template.</p>
<code>wp-templates/front-page.js</code>
</div>
</Container>
</Main>
<Footer title={siteTitle} menuItems={footerMenu} />
</>
);
}
Component.query = gql`
${BlogInfoFragment}
${NavigationMenu.fragments.entry}
query GetPageData(
$headerLocation: MenuLocationEnum
$footerLocation: MenuLocationEnum
) {
generalSettings {
...BlogInfoFragment
}
headerMenuItems: menuItems(where: { location: $headerLocation }) {
nodes {
...NavigationMenuItemFragment
}
}
footerMenuItems: menuItems(where: { location: $footerLocation }) {
nodes {
...NavigationMenuItemFragment
}
}
}
`;
Component.variables = () => {
return {
headerLocation: MENUS.PRIMARY_LOCATION,
footerLocation: MENUS.FOOTER_LOCATION,
};
};