質問編集履歴
3
問題解決のためコードを削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
};
|
12
12
|
```
|
13
13
|
```js
|
14
|
-
const
|
14
|
+
const Test = ({ location }) => {
|
15
15
|
return (
|
16
16
|
<Example word1="ファイル名1" word2="説明1" />
|
17
17
|
<Example word1="ファイル名2" word2="説明2" />
|
@@ -38,206 +38,4 @@
|
|
38
38
|
初心者すぎて当たり前のことがわからないのでその点よろしくお願いします。
|
39
39
|
|
40
40
|
####追記:実際のコード(解決後削除予定)
|
41
|
-
- index.js
|
42
|
-
```js
|
43
|
-
import React from "react";
|
44
|
-
import { graphql } from "gatsby";
|
45
|
-
import { Helmet } from "react-helmet";
|
46
|
-
|
47
|
-
import Layout from "../components/Layout";
|
48
|
-
import SEO from "../components/SEO";
|
49
|
-
import PostCard from "../components/PostCard";
|
50
|
-
import CategoryMenu from "../components/CategoryMenu";
|
51
|
-
import HomeJsonLd from "../components/json/HomeJsonLd";
|
52
|
-
|
53
|
-
class BlogIndex extends React.Component {
|
54
|
-
render() {
|
55
|
-
const { data } = this.props;
|
56
|
-
const siteTitle = data.site.siteMetadata.title;
|
57
|
-
const posts = data.allMarkdownRemark.edges;
|
58
|
-
const { location } = this.props;
|
59
|
-
|
60
|
-
return (
|
61
|
-
<Layout location={this.props.location} title={siteTitle}>
|
62
|
-
<SEO title="" />
|
63
|
-
<Helmet>
|
64
|
-
<link rel="canonical" href="https://catnose99.com" />
|
65
|
-
</Helmet>
|
66
|
-
<HomeJsonLd />
|
67
|
-
<CategoryMenu location={location} />
|
68
|
-
{posts.map(({ node }) => {
|
69
|
-
return <PostCard key={node.fields.slug} node={node} />;
|
70
|
-
})}
|
71
|
-
</Layout>
|
72
|
-
);
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
export default BlogIndex;
|
77
|
-
|
78
|
-
export const pageQuery = graphql`
|
79
|
-
query {
|
80
|
-
site {
|
81
|
-
siteMetadata {
|
82
|
-
title
|
83
|
-
}
|
84
|
-
}
|
85
|
-
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
|
86
|
-
edges {
|
87
|
-
node {
|
88
|
-
fields {
|
89
|
-
|
41
|
+
削除済み
|
90
|
-
}
|
91
|
-
frontmatter {
|
92
|
-
date(formatString: "YYYY.MM.DD")
|
93
|
-
title
|
94
|
-
emoji
|
95
|
-
category
|
96
|
-
}
|
97
|
-
}
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
101
|
-
`;
|
102
|
-
|
103
|
-
```
|
104
|
-
- CategoryMenu.js
|
105
|
-
```js
|
106
|
-
import React from "react";
|
107
|
-
import styled from "styled-components";
|
108
|
-
import { Link } from "gatsby";
|
109
|
-
import svgNew from "../svg/categories/new.svg";
|
110
|
-
|
111
|
-
|
112
|
-
const Nav = styled.nav`
|
113
|
-
display: block;
|
114
|
-
margin: 0;
|
115
|
-
padding: 0 0 2em;
|
116
|
-
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
117
|
-
padding: 1em 0;
|
118
|
-
}
|
119
|
-
`;
|
120
|
-
|
121
|
-
const CategoryItemList = styled.ul`
|
122
|
-
display: flex;
|
123
|
-
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
124
|
-
margin: 0 -20px;
|
125
|
-
flex-wrap: nowrap;
|
126
|
-
overflow-x: auto;
|
127
|
-
-webkit-overflow-scrolling: touch;
|
128
|
-
::-webkit-scrollbar {
|
129
|
-
display: none;
|
130
|
-
}
|
131
|
-
&:after {
|
132
|
-
content: "";
|
133
|
-
width: 40px;
|
134
|
-
flex: 0 0 auto;
|
135
|
-
}
|
136
|
-
}
|
137
|
-
`;
|
138
|
-
|
139
|
-
const CategoryItem = styled.li`
|
140
|
-
width: 70px;
|
141
|
-
margin: 0 20px 0 0;
|
142
|
-
text-align: center;
|
143
|
-
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
144
|
-
width: 60px;
|
145
|
-
flex: 0 0 auto;
|
146
|
-
margin: 0 0 0 15px;
|
147
|
-
}
|
148
|
-
.cat-item__link {
|
149
|
-
color: #fff;
|
150
|
-
}
|
151
|
-
|
152
|
-
.cat-item__image {
|
153
|
-
padding: 2px;
|
154
|
-
background: ${(props) => props.theme.colors.blackLight};
|
155
|
-
border-radius: 50%;
|
156
|
-
position: relative;
|
157
|
-
img {
|
158
|
-
position: relative;
|
159
|
-
background: ${(props) => props.theme.colors.blackLight};
|
160
|
-
border-radius: 50%;
|
161
|
-
display: block;
|
162
|
-
z-index: 2;
|
163
|
-
}
|
164
|
-
}
|
165
|
-
.cat-item__name {
|
166
|
-
margin-top: 5px;
|
167
|
-
font-size: 13px;
|
168
|
-
font-weight: 700;
|
169
|
-
letter-spacing: 0.5px;
|
170
|
-
color: ${(props) => props.theme.colors.gray};
|
171
|
-
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
172
|
-
font-size: 12px;
|
173
|
-
}
|
174
|
-
}
|
175
|
-
&.active {
|
176
|
-
.cat-item__image:after {
|
177
|
-
content: "";
|
178
|
-
position: absolute;
|
179
|
-
display: block;
|
180
|
-
left: 0;
|
181
|
-
top: 0;
|
182
|
-
width: 100%;
|
183
|
-
height: 100%;
|
184
|
-
border-radius: 50%;
|
185
|
-
background: ${(props) => props.theme.colors.gradient};
|
186
|
-
animation: rotating 2s linear infinite;
|
187
|
-
}
|
188
|
-
img {
|
189
|
-
border: solid 2px ${(props) => props.theme.colors.background};
|
190
|
-
}
|
191
|
-
}
|
192
|
-
@keyframes rotating {
|
193
|
-
from {
|
194
|
-
transform: rotate(0deg);
|
195
|
-
}
|
196
|
-
to {
|
197
|
-
transform: rotate(360deg);
|
198
|
-
}
|
199
|
-
}
|
200
|
-
`;
|
201
|
-
|
202
|
-
const CategoryLink = ({ catName, iconid, catLink, path }) => {
|
203
|
-
return (
|
204
|
-
<CategoryItem className={catLink === path && "active"}>
|
205
|
-
<Link to={catLink} className="cat-item__link">
|
206
|
-
<div className="cat-item__image">
|
207
|
-
<img
|
208
|
-
src={"https://twemoji.maxcdn.com/2/svg/" + { iconid } + ".svg"}
|
209
|
-
alt={catName}
|
210
|
-
/>
|
211
|
-
</div>
|
212
|
-
<div className="cat-item__name">{catName}</div>
|
213
|
-
</Link>
|
214
|
-
</CategoryItem>
|
215
|
-
);
|
216
|
-
};
|
217
|
-
|
218
|
-
const CategoryMenu = ({ location }) => {
|
219
|
-
const path = location.pathname;
|
220
|
-
return (
|
221
|
-
<Nav>
|
222
|
-
<CategoryItemList>
|
223
|
-
<CategoryLink catName="New" catIcon={svgNew} catLink="/" path={path} />
|
224
|
-
<CategoryLink
|
225
|
-
catName="TaikoSim"
|
226
|
-
iconid="1f941"
|
227
|
-
catLink="/category/design"
|
228
|
-
path={path}
|
229
|
-
/>
|
230
|
-
<CategoryLink
|
231
|
-
catName="Dev"
|
232
|
-
iconid="1f916"
|
233
|
-
catLink="/category/dev"
|
234
|
-
path={path}
|
235
|
-
/>
|
236
|
-
</CategoryItemList>
|
237
|
-
</Nav>
|
238
|
-
);
|
239
|
-
};
|
240
|
-
|
241
|
-
export default CategoryMenu;
|
242
|
-
|
243
|
-
```
|
2
実際のコードを記述
title
CHANGED
File without changes
|
body
CHANGED
@@ -35,4 +35,209 @@
|
|
35
35
|
```
|
36
36
|
|
37
37
|
#補足情報
|
38
|
-
初心者すぎて当たり前のことがわからないのでその点よろしくお願いします。
|
38
|
+
初心者すぎて当たり前のことがわからないのでその点よろしくお願いします。
|
39
|
+
|
40
|
+
####追記:実際のコード(解決後削除予定)
|
41
|
+
- index.js
|
42
|
+
```js
|
43
|
+
import React from "react";
|
44
|
+
import { graphql } from "gatsby";
|
45
|
+
import { Helmet } from "react-helmet";
|
46
|
+
|
47
|
+
import Layout from "../components/Layout";
|
48
|
+
import SEO from "../components/SEO";
|
49
|
+
import PostCard from "../components/PostCard";
|
50
|
+
import CategoryMenu from "../components/CategoryMenu";
|
51
|
+
import HomeJsonLd from "../components/json/HomeJsonLd";
|
52
|
+
|
53
|
+
class BlogIndex extends React.Component {
|
54
|
+
render() {
|
55
|
+
const { data } = this.props;
|
56
|
+
const siteTitle = data.site.siteMetadata.title;
|
57
|
+
const posts = data.allMarkdownRemark.edges;
|
58
|
+
const { location } = this.props;
|
59
|
+
|
60
|
+
return (
|
61
|
+
<Layout location={this.props.location} title={siteTitle}>
|
62
|
+
<SEO title="" />
|
63
|
+
<Helmet>
|
64
|
+
<link rel="canonical" href="https://catnose99.com" />
|
65
|
+
</Helmet>
|
66
|
+
<HomeJsonLd />
|
67
|
+
<CategoryMenu location={location} />
|
68
|
+
{posts.map(({ node }) => {
|
69
|
+
return <PostCard key={node.fields.slug} node={node} />;
|
70
|
+
})}
|
71
|
+
</Layout>
|
72
|
+
);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
export default BlogIndex;
|
77
|
+
|
78
|
+
export const pageQuery = graphql`
|
79
|
+
query {
|
80
|
+
site {
|
81
|
+
siteMetadata {
|
82
|
+
title
|
83
|
+
}
|
84
|
+
}
|
85
|
+
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
|
86
|
+
edges {
|
87
|
+
node {
|
88
|
+
fields {
|
89
|
+
slug
|
90
|
+
}
|
91
|
+
frontmatter {
|
92
|
+
date(formatString: "YYYY.MM.DD")
|
93
|
+
title
|
94
|
+
emoji
|
95
|
+
category
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
`;
|
102
|
+
|
103
|
+
```
|
104
|
+
- CategoryMenu.js
|
105
|
+
```js
|
106
|
+
import React from "react";
|
107
|
+
import styled from "styled-components";
|
108
|
+
import { Link } from "gatsby";
|
109
|
+
import svgNew from "../svg/categories/new.svg";
|
110
|
+
|
111
|
+
|
112
|
+
const Nav = styled.nav`
|
113
|
+
display: block;
|
114
|
+
margin: 0;
|
115
|
+
padding: 0 0 2em;
|
116
|
+
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
117
|
+
padding: 1em 0;
|
118
|
+
}
|
119
|
+
`;
|
120
|
+
|
121
|
+
const CategoryItemList = styled.ul`
|
122
|
+
display: flex;
|
123
|
+
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
124
|
+
margin: 0 -20px;
|
125
|
+
flex-wrap: nowrap;
|
126
|
+
overflow-x: auto;
|
127
|
+
-webkit-overflow-scrolling: touch;
|
128
|
+
::-webkit-scrollbar {
|
129
|
+
display: none;
|
130
|
+
}
|
131
|
+
&:after {
|
132
|
+
content: "";
|
133
|
+
width: 40px;
|
134
|
+
flex: 0 0 auto;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
`;
|
138
|
+
|
139
|
+
const CategoryItem = styled.li`
|
140
|
+
width: 70px;
|
141
|
+
margin: 0 20px 0 0;
|
142
|
+
text-align: center;
|
143
|
+
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
144
|
+
width: 60px;
|
145
|
+
flex: 0 0 auto;
|
146
|
+
margin: 0 0 0 15px;
|
147
|
+
}
|
148
|
+
.cat-item__link {
|
149
|
+
color: #fff;
|
150
|
+
}
|
151
|
+
|
152
|
+
.cat-item__image {
|
153
|
+
padding: 2px;
|
154
|
+
background: ${(props) => props.theme.colors.blackLight};
|
155
|
+
border-radius: 50%;
|
156
|
+
position: relative;
|
157
|
+
img {
|
158
|
+
position: relative;
|
159
|
+
background: ${(props) => props.theme.colors.blackLight};
|
160
|
+
border-radius: 50%;
|
161
|
+
display: block;
|
162
|
+
z-index: 2;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
.cat-item__name {
|
166
|
+
margin-top: 5px;
|
167
|
+
font-size: 13px;
|
168
|
+
font-weight: 700;
|
169
|
+
letter-spacing: 0.5px;
|
170
|
+
color: ${(props) => props.theme.colors.gray};
|
171
|
+
@media screen and (max-width: ${(props) => props.theme.responsive.small}) {
|
172
|
+
font-size: 12px;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
&.active {
|
176
|
+
.cat-item__image:after {
|
177
|
+
content: "";
|
178
|
+
position: absolute;
|
179
|
+
display: block;
|
180
|
+
left: 0;
|
181
|
+
top: 0;
|
182
|
+
width: 100%;
|
183
|
+
height: 100%;
|
184
|
+
border-radius: 50%;
|
185
|
+
background: ${(props) => props.theme.colors.gradient};
|
186
|
+
animation: rotating 2s linear infinite;
|
187
|
+
}
|
188
|
+
img {
|
189
|
+
border: solid 2px ${(props) => props.theme.colors.background};
|
190
|
+
}
|
191
|
+
}
|
192
|
+
@keyframes rotating {
|
193
|
+
from {
|
194
|
+
transform: rotate(0deg);
|
195
|
+
}
|
196
|
+
to {
|
197
|
+
transform: rotate(360deg);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
`;
|
201
|
+
|
202
|
+
const CategoryLink = ({ catName, iconid, catLink, path }) => {
|
203
|
+
return (
|
204
|
+
<CategoryItem className={catLink === path && "active"}>
|
205
|
+
<Link to={catLink} className="cat-item__link">
|
206
|
+
<div className="cat-item__image">
|
207
|
+
<img
|
208
|
+
src={"https://twemoji.maxcdn.com/2/svg/" + { iconid } + ".svg"}
|
209
|
+
alt={catName}
|
210
|
+
/>
|
211
|
+
</div>
|
212
|
+
<div className="cat-item__name">{catName}</div>
|
213
|
+
</Link>
|
214
|
+
</CategoryItem>
|
215
|
+
);
|
216
|
+
};
|
217
|
+
|
218
|
+
const CategoryMenu = ({ location }) => {
|
219
|
+
const path = location.pathname;
|
220
|
+
return (
|
221
|
+
<Nav>
|
222
|
+
<CategoryItemList>
|
223
|
+
<CategoryLink catName="New" catIcon={svgNew} catLink="/" path={path} />
|
224
|
+
<CategoryLink
|
225
|
+
catName="TaikoSim"
|
226
|
+
iconid="1f941"
|
227
|
+
catLink="/category/design"
|
228
|
+
path={path}
|
229
|
+
/>
|
230
|
+
<CategoryLink
|
231
|
+
catName="Dev"
|
232
|
+
iconid="1f916"
|
233
|
+
catLink="/category/dev"
|
234
|
+
path={path}
|
235
|
+
/>
|
236
|
+
</CategoryItemList>
|
237
|
+
</Nav>
|
238
|
+
);
|
239
|
+
};
|
240
|
+
|
241
|
+
export default CategoryMenu;
|
242
|
+
|
243
|
+
```
|
1
誤字のため修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#やってみたこと
|
4
4
|
ソースコードはざっくりです。
|
5
5
|
```js
|
6
|
-
const Example = ({
|
6
|
+
const Example = ({ word1, word2 }) => {
|
7
7
|
return (
|
8
8
|
<img src={"https://example.maxcdn.com/" + {word1} + ".jpg" } alt={word2} />
|
9
9
|
....
|