質問編集履歴

3

問題解決のためコードを削除

2020/12/31 08:44

投稿

j11
j11

スコア2

test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  ```js
26
26
 
27
- const CategoryMenu = ({ location }) => {
27
+ const Test = ({ location }) => {
28
28
 
29
29
  return (
30
30
 
@@ -78,408 +78,4 @@
78
78
 
79
79
  ####追記:実際のコード(解決後削除予定)
80
80
 
81
- - index.js
82
-
83
- ```js
84
-
85
- import React from "react";
86
-
87
- import { graphql } from "gatsby";
88
-
89
- import { Helmet } from "react-helmet";
90
-
91
-
92
-
93
- import Layout from "../components/Layout";
94
-
95
- import SEO from "../components/SEO";
96
-
97
- import PostCard from "../components/PostCard";
98
-
99
- import CategoryMenu from "../components/CategoryMenu";
100
-
101
- import HomeJsonLd from "../components/json/HomeJsonLd";
102
-
103
-
104
-
105
- class BlogIndex extends React.Component {
106
-
107
- render() {
108
-
109
- const { data } = this.props;
110
-
111
- const siteTitle = data.site.siteMetadata.title;
112
-
113
- const posts = data.allMarkdownRemark.edges;
114
-
115
- const { location } = this.props;
116
-
117
-
118
-
119
- return (
120
-
121
- <Layout location={this.props.location} title={siteTitle}>
122
-
123
- <SEO title="" />
124
-
125
- <Helmet>
126
-
127
- <link rel="canonical" href="https://catnose99.com" />
128
-
129
- </Helmet>
130
-
131
- <HomeJsonLd />
132
-
133
- <CategoryMenu location={location} />
134
-
135
- {posts.map(({ node }) => {
136
-
137
- return <PostCard key={node.fields.slug} node={node} />;
138
-
139
- })}
140
-
141
- </Layout>
142
-
143
- );
144
-
145
- }
146
-
147
- }
148
-
149
-
150
-
151
- export default BlogIndex;
152
-
153
-
154
-
155
- export const pageQuery = graphql`
156
-
157
- query {
158
-
159
- site {
160
-
161
- siteMetadata {
162
-
163
- title
164
-
165
- }
166
-
167
- }
168
-
169
- allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
170
-
171
- edges {
172
-
173
- node {
174
-
175
- fields {
176
-
177
- slug
81
+ 削除済み
178
-
179
- }
180
-
181
- frontmatter {
182
-
183
- date(formatString: "YYYY.MM.DD")
184
-
185
- title
186
-
187
- emoji
188
-
189
- category
190
-
191
- }
192
-
193
- }
194
-
195
- }
196
-
197
- }
198
-
199
- }
200
-
201
- `;
202
-
203
-
204
-
205
- ```
206
-
207
- - CategoryMenu.js
208
-
209
- ```js
210
-
211
- import React from "react";
212
-
213
- import styled from "styled-components";
214
-
215
- import { Link } from "gatsby";
216
-
217
- import svgNew from "../svg/categories/new.svg";
218
-
219
-
220
-
221
-
222
-
223
- const Nav = styled.nav`
224
-
225
- display: block;
226
-
227
- margin: 0;
228
-
229
- padding: 0 0 2em;
230
-
231
- @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
232
-
233
- padding: 1em 0;
234
-
235
- }
236
-
237
- `;
238
-
239
-
240
-
241
- const CategoryItemList = styled.ul`
242
-
243
- display: flex;
244
-
245
- @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
246
-
247
- margin: 0 -20px;
248
-
249
- flex-wrap: nowrap;
250
-
251
- overflow-x: auto;
252
-
253
- -webkit-overflow-scrolling: touch;
254
-
255
- ::-webkit-scrollbar {
256
-
257
- display: none;
258
-
259
- }
260
-
261
- &:after {
262
-
263
- content: "";
264
-
265
- width: 40px;
266
-
267
- flex: 0 0 auto;
268
-
269
- }
270
-
271
- }
272
-
273
- `;
274
-
275
-
276
-
277
- const CategoryItem = styled.li`
278
-
279
- width: 70px;
280
-
281
- margin: 0 20px 0 0;
282
-
283
- text-align: center;
284
-
285
- @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
286
-
287
- width: 60px;
288
-
289
- flex: 0 0 auto;
290
-
291
- margin: 0 0 0 15px;
292
-
293
- }
294
-
295
- .cat-item__link {
296
-
297
- color: #fff;
298
-
299
- }
300
-
301
-
302
-
303
- .cat-item__image {
304
-
305
- padding: 2px;
306
-
307
- background: ${(props) => props.theme.colors.blackLight};
308
-
309
- border-radius: 50%;
310
-
311
- position: relative;
312
-
313
- img {
314
-
315
- position: relative;
316
-
317
- background: ${(props) => props.theme.colors.blackLight};
318
-
319
- border-radius: 50%;
320
-
321
- display: block;
322
-
323
- z-index: 2;
324
-
325
- }
326
-
327
- }
328
-
329
- .cat-item__name {
330
-
331
- margin-top: 5px;
332
-
333
- font-size: 13px;
334
-
335
- font-weight: 700;
336
-
337
- letter-spacing: 0.5px;
338
-
339
- color: ${(props) => props.theme.colors.gray};
340
-
341
- @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
342
-
343
- font-size: 12px;
344
-
345
- }
346
-
347
- }
348
-
349
- &.active {
350
-
351
- .cat-item__image:after {
352
-
353
- content: "";
354
-
355
- position: absolute;
356
-
357
- display: block;
358
-
359
- left: 0;
360
-
361
- top: 0;
362
-
363
- width: 100%;
364
-
365
- height: 100%;
366
-
367
- border-radius: 50%;
368
-
369
- background: ${(props) => props.theme.colors.gradient};
370
-
371
- animation: rotating 2s linear infinite;
372
-
373
- }
374
-
375
- img {
376
-
377
- border: solid 2px ${(props) => props.theme.colors.background};
378
-
379
- }
380
-
381
- }
382
-
383
- @keyframes rotating {
384
-
385
- from {
386
-
387
- transform: rotate(0deg);
388
-
389
- }
390
-
391
- to {
392
-
393
- transform: rotate(360deg);
394
-
395
- }
396
-
397
- }
398
-
399
- `;
400
-
401
-
402
-
403
- const CategoryLink = ({ catName, iconid, catLink, path }) => {
404
-
405
- return (
406
-
407
- <CategoryItem className={catLink === path && "active"}>
408
-
409
- <Link to={catLink} className="cat-item__link">
410
-
411
- <div className="cat-item__image">
412
-
413
- <img
414
-
415
- src={"https://twemoji.maxcdn.com/2/svg/" + { iconid } + ".svg"}
416
-
417
- alt={catName}
418
-
419
- />
420
-
421
- </div>
422
-
423
- <div className="cat-item__name">{catName}</div>
424
-
425
- </Link>
426
-
427
- </CategoryItem>
428
-
429
- );
430
-
431
- };
432
-
433
-
434
-
435
- const CategoryMenu = ({ location }) => {
436
-
437
- const path = location.pathname;
438
-
439
- return (
440
-
441
- <Nav>
442
-
443
- <CategoryItemList>
444
-
445
- <CategoryLink catName="New" catIcon={svgNew} catLink="/" path={path} />
446
-
447
- <CategoryLink
448
-
449
- catName="TaikoSim"
450
-
451
- iconid="1f941"
452
-
453
- catLink="/category/design"
454
-
455
- path={path}
456
-
457
- />
458
-
459
- <CategoryLink
460
-
461
- catName="Dev"
462
-
463
- iconid="1f916"
464
-
465
- catLink="/category/dev"
466
-
467
- path={path}
468
-
469
- />
470
-
471
- </CategoryItemList>
472
-
473
- </Nav>
474
-
475
- );
476
-
477
- };
478
-
479
-
480
-
481
- export default CategoryMenu;
482
-
483
-
484
-
485
- ```

2

実際のコードを記述

2020/12/31 08:44

投稿

j11
j11

スコア2

test CHANGED
File without changes
test CHANGED
@@ -73,3 +73,413 @@
73
73
  #補足情報
74
74
 
75
75
  初心者すぎて当たり前のことがわからないのでその点よろしくお願いします。
76
+
77
+
78
+
79
+ ####追記:実際のコード(解決後削除予定)
80
+
81
+ - index.js
82
+
83
+ ```js
84
+
85
+ import React from "react";
86
+
87
+ import { graphql } from "gatsby";
88
+
89
+ import { Helmet } from "react-helmet";
90
+
91
+
92
+
93
+ import Layout from "../components/Layout";
94
+
95
+ import SEO from "../components/SEO";
96
+
97
+ import PostCard from "../components/PostCard";
98
+
99
+ import CategoryMenu from "../components/CategoryMenu";
100
+
101
+ import HomeJsonLd from "../components/json/HomeJsonLd";
102
+
103
+
104
+
105
+ class BlogIndex extends React.Component {
106
+
107
+ render() {
108
+
109
+ const { data } = this.props;
110
+
111
+ const siteTitle = data.site.siteMetadata.title;
112
+
113
+ const posts = data.allMarkdownRemark.edges;
114
+
115
+ const { location } = this.props;
116
+
117
+
118
+
119
+ return (
120
+
121
+ <Layout location={this.props.location} title={siteTitle}>
122
+
123
+ <SEO title="" />
124
+
125
+ <Helmet>
126
+
127
+ <link rel="canonical" href="https://catnose99.com" />
128
+
129
+ </Helmet>
130
+
131
+ <HomeJsonLd />
132
+
133
+ <CategoryMenu location={location} />
134
+
135
+ {posts.map(({ node }) => {
136
+
137
+ return <PostCard key={node.fields.slug} node={node} />;
138
+
139
+ })}
140
+
141
+ </Layout>
142
+
143
+ );
144
+
145
+ }
146
+
147
+ }
148
+
149
+
150
+
151
+ export default BlogIndex;
152
+
153
+
154
+
155
+ export const pageQuery = graphql`
156
+
157
+ query {
158
+
159
+ site {
160
+
161
+ siteMetadata {
162
+
163
+ title
164
+
165
+ }
166
+
167
+ }
168
+
169
+ allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
170
+
171
+ edges {
172
+
173
+ node {
174
+
175
+ fields {
176
+
177
+ slug
178
+
179
+ }
180
+
181
+ frontmatter {
182
+
183
+ date(formatString: "YYYY.MM.DD")
184
+
185
+ title
186
+
187
+ emoji
188
+
189
+ category
190
+
191
+ }
192
+
193
+ }
194
+
195
+ }
196
+
197
+ }
198
+
199
+ }
200
+
201
+ `;
202
+
203
+
204
+
205
+ ```
206
+
207
+ - CategoryMenu.js
208
+
209
+ ```js
210
+
211
+ import React from "react";
212
+
213
+ import styled from "styled-components";
214
+
215
+ import { Link } from "gatsby";
216
+
217
+ import svgNew from "../svg/categories/new.svg";
218
+
219
+
220
+
221
+
222
+
223
+ const Nav = styled.nav`
224
+
225
+ display: block;
226
+
227
+ margin: 0;
228
+
229
+ padding: 0 0 2em;
230
+
231
+ @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
232
+
233
+ padding: 1em 0;
234
+
235
+ }
236
+
237
+ `;
238
+
239
+
240
+
241
+ const CategoryItemList = styled.ul`
242
+
243
+ display: flex;
244
+
245
+ @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
246
+
247
+ margin: 0 -20px;
248
+
249
+ flex-wrap: nowrap;
250
+
251
+ overflow-x: auto;
252
+
253
+ -webkit-overflow-scrolling: touch;
254
+
255
+ ::-webkit-scrollbar {
256
+
257
+ display: none;
258
+
259
+ }
260
+
261
+ &:after {
262
+
263
+ content: "";
264
+
265
+ width: 40px;
266
+
267
+ flex: 0 0 auto;
268
+
269
+ }
270
+
271
+ }
272
+
273
+ `;
274
+
275
+
276
+
277
+ const CategoryItem = styled.li`
278
+
279
+ width: 70px;
280
+
281
+ margin: 0 20px 0 0;
282
+
283
+ text-align: center;
284
+
285
+ @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
286
+
287
+ width: 60px;
288
+
289
+ flex: 0 0 auto;
290
+
291
+ margin: 0 0 0 15px;
292
+
293
+ }
294
+
295
+ .cat-item__link {
296
+
297
+ color: #fff;
298
+
299
+ }
300
+
301
+
302
+
303
+ .cat-item__image {
304
+
305
+ padding: 2px;
306
+
307
+ background: ${(props) => props.theme.colors.blackLight};
308
+
309
+ border-radius: 50%;
310
+
311
+ position: relative;
312
+
313
+ img {
314
+
315
+ position: relative;
316
+
317
+ background: ${(props) => props.theme.colors.blackLight};
318
+
319
+ border-radius: 50%;
320
+
321
+ display: block;
322
+
323
+ z-index: 2;
324
+
325
+ }
326
+
327
+ }
328
+
329
+ .cat-item__name {
330
+
331
+ margin-top: 5px;
332
+
333
+ font-size: 13px;
334
+
335
+ font-weight: 700;
336
+
337
+ letter-spacing: 0.5px;
338
+
339
+ color: ${(props) => props.theme.colors.gray};
340
+
341
+ @media screen and (max-width: ${(props) => props.theme.responsive.small}) {
342
+
343
+ font-size: 12px;
344
+
345
+ }
346
+
347
+ }
348
+
349
+ &.active {
350
+
351
+ .cat-item__image:after {
352
+
353
+ content: "";
354
+
355
+ position: absolute;
356
+
357
+ display: block;
358
+
359
+ left: 0;
360
+
361
+ top: 0;
362
+
363
+ width: 100%;
364
+
365
+ height: 100%;
366
+
367
+ border-radius: 50%;
368
+
369
+ background: ${(props) => props.theme.colors.gradient};
370
+
371
+ animation: rotating 2s linear infinite;
372
+
373
+ }
374
+
375
+ img {
376
+
377
+ border: solid 2px ${(props) => props.theme.colors.background};
378
+
379
+ }
380
+
381
+ }
382
+
383
+ @keyframes rotating {
384
+
385
+ from {
386
+
387
+ transform: rotate(0deg);
388
+
389
+ }
390
+
391
+ to {
392
+
393
+ transform: rotate(360deg);
394
+
395
+ }
396
+
397
+ }
398
+
399
+ `;
400
+
401
+
402
+
403
+ const CategoryLink = ({ catName, iconid, catLink, path }) => {
404
+
405
+ return (
406
+
407
+ <CategoryItem className={catLink === path && "active"}>
408
+
409
+ <Link to={catLink} className="cat-item__link">
410
+
411
+ <div className="cat-item__image">
412
+
413
+ <img
414
+
415
+ src={"https://twemoji.maxcdn.com/2/svg/" + { iconid } + ".svg"}
416
+
417
+ alt={catName}
418
+
419
+ />
420
+
421
+ </div>
422
+
423
+ <div className="cat-item__name">{catName}</div>
424
+
425
+ </Link>
426
+
427
+ </CategoryItem>
428
+
429
+ );
430
+
431
+ };
432
+
433
+
434
+
435
+ const CategoryMenu = ({ location }) => {
436
+
437
+ const path = location.pathname;
438
+
439
+ return (
440
+
441
+ <Nav>
442
+
443
+ <CategoryItemList>
444
+
445
+ <CategoryLink catName="New" catIcon={svgNew} catLink="/" path={path} />
446
+
447
+ <CategoryLink
448
+
449
+ catName="TaikoSim"
450
+
451
+ iconid="1f941"
452
+
453
+ catLink="/category/design"
454
+
455
+ path={path}
456
+
457
+ />
458
+
459
+ <CategoryLink
460
+
461
+ catName="Dev"
462
+
463
+ iconid="1f916"
464
+
465
+ catLink="/category/dev"
466
+
467
+ path={path}
468
+
469
+ />
470
+
471
+ </CategoryItemList>
472
+
473
+ </Nav>
474
+
475
+ );
476
+
477
+ };
478
+
479
+
480
+
481
+ export default CategoryMenu;
482
+
483
+
484
+
485
+ ```

1

誤字のため修正

2020/12/30 02:11

投稿

j11
j11

スコア2

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ```js
10
10
 
11
- const Example = ({ Word1, Word2 }) => {
11
+ const Example = ({ word1, word2 }) => {
12
12
 
13
13
  return (
14
14