-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.jsx
118 lines (112 loc) · 2.83 KB
/
index.jsx
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import Blog from "src/components/Blog";
import Button from "src/components/Button";
import Github from "src/components/Github";
import Hero from "src/components/Hero";
import Portfolio from "src/components/Portfolio";
import useWindowSize from "src/hooks/useWindowSize";
import Layout from "src/components/Layout/Layout";
import { client } from "src/libs/client";
const { graphql } = require("@octokit/graphql");
export const getStaticProps = async () => {
//ブログデータ取得
const blogData = await client.getList({
endpoint: "blog",
});
//ポートフォリオデータ取得
const portfolioData = await client.getList({
endpoint: "portfolio",
});
//GitHubデータ取得
const graphqlWithAuth = graphql.defaults({
headers: {
authorization: `token ${process.env.GITHUB_TOKEN}`,
},
});
const QUERY = `
query getUser($login: String!) {
user(login: $login) {
name
url
repositories(last:5
ownerAffiliations: [OWNER]){
nodes{
name
description
url
id
stargazers{
totalCount
}
forks{
totalCount
}
languages (first:8){
totalSize
edges{
size
node{
id
name
color
}
}
}
}
}
}
}
`;
// const { user } = await graphqlWithAuth(QUERY, {
// login: "tocchi-739",
// });
return {
props: {
blog: blogData,
portfolio: portfolioData,
// github: user,
},
revalidate: 10,
};
};
const Home = (props) => {
const width = useWindowSize();
// const githubUser = {
// name: props.github.name,
// url: props.github.url,
// };
return (
<Layout title={"Home"}>
<Hero />
<div className="mx-4 mt-10">
{width < 640 ? (
<Blog blogData={props.blog.contents.slice(0, 4)} />
) : (
<Blog blogData={props.blog.contents.slice(0, 5)} />
)}
<Button text="View All" href="/blogPage/page/1" />
</div>
<div className="mx-4 mt-[61px] md:mt-[100px]">
{width < 640 ? (
<Portfolio portfolioList={props.portfolio.contents.slice(0, 3)} />
) : (
<Portfolio portfolioList={props.portfolio.contents} />
)}
<Button text="View All" href="/portfolioPage" />
</div>
<div className="md:grid md:grid-cols-2 md:gap-20">
{/* {width < 640 ? (
<Github
githubList={props.github.repositories.nodes.slice(0, 3)}
githubUser={githubUser}
/>
) : (
<Github
githubList={props.github.repositories.nodes}
githubUser={githubUser}
/>
)} */}
</div>
</Layout>
);
};
export default Home;