質問編集履歴
2
改善した後のエラー内容
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,10 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
`lib/posts.js`
|
20
|
+
|
21
|
+
|
22
|
+
|
19
23
|
```javascript
|
20
24
|
|
21
25
|
export async function getSortedPostsData() {
|
@@ -34,7 +38,7 @@
|
|
34
38
|
|
35
39
|
|
36
40
|
|
37
|
-
const allPostsData = fileNames.map(fileName => {
|
41
|
+
const allPostsData = fileNames.map(async (fileName) => {
|
38
42
|
|
39
43
|
// Remove ".md" from file name to get id
|
40
44
|
|
@@ -46,9 +50,9 @@
|
|
46
50
|
|
47
51
|
const repoUrl_tmp = `https://api.github.com/repos/satorun082/article/contents/${id}.md`
|
48
52
|
|
49
|
-
const response_tmp = fetch(repoUrl_tmp)
|
53
|
+
const response_tmp = await fetch(repoUrl_tmp)
|
50
|
-
|
54
|
+
|
51
|
-
const file_tmp = response_tmp.json()
|
55
|
+
const file_tmp = await response_tmp.json()
|
52
56
|
|
53
57
|
const fileContents = base64.decode(file_tmp.content)
|
54
58
|
|
@@ -72,8 +76,6 @@
|
|
72
76
|
|
73
77
|
})
|
74
78
|
|
75
|
-
|
76
|
-
|
77
79
|
// Sort posts by date
|
78
80
|
|
79
81
|
return await allPostsData.sort(({ date: a }, { date: b }) => {
|
@@ -100,51 +102,189 @@
|
|
100
102
|
|
101
103
|
|
102
104
|
|
105
|
+
`index.tsx`
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
import { GetStaticProps } from 'next'
|
112
|
+
|
113
|
+
import Head from 'next/head'
|
114
|
+
|
115
|
+
import Layout, { siteTitle } from '../components/layout'
|
116
|
+
|
117
|
+
import utilStyles from '../styles/utils.module.css'
|
118
|
+
|
119
|
+
import { getSortedPostsData } from '../lib/posts'
|
120
|
+
|
121
|
+
import Link from 'next/link'
|
122
|
+
|
123
|
+
import Date from '../components/date'
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
export const getStaticProps: GetStaticProps = async() => {
|
128
|
+
|
129
|
+
const allPostsData = await getSortedPostsData()
|
130
|
+
|
131
|
+
return {
|
132
|
+
|
133
|
+
props: {
|
134
|
+
|
135
|
+
allPostsData
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
type Props = {
|
146
|
+
|
147
|
+
allPostsData: {
|
148
|
+
|
149
|
+
id: string
|
150
|
+
|
151
|
+
title: string
|
152
|
+
|
153
|
+
date: string
|
154
|
+
|
155
|
+
}[]
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
export default function Home({ allPostsData }: Props) {
|
162
|
+
|
163
|
+
return (
|
164
|
+
|
165
|
+
<Layout home>
|
166
|
+
|
167
|
+
<Head>
|
168
|
+
|
169
|
+
<title>{siteTitle}</title>
|
170
|
+
|
171
|
+
</Head>
|
172
|
+
|
173
|
+
<section className={utilStyles.headingMd}>
|
174
|
+
|
175
|
+
<p>Im nakadats and Im learning English to make my brondy girl friends</p>
|
176
|
+
|
177
|
+
<p>
|
178
|
+
|
179
|
+
(This is a sample website - you’ll be building a site like this on{' '}
|
180
|
+
|
181
|
+
<a href="https://nextjs.org/learn">our Next.js tutorial</a>.)
|
182
|
+
|
183
|
+
</p>
|
184
|
+
|
185
|
+
</section>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<section className={`${utilStyles.headingMd} ${utilStyles.padding1px}`}>
|
190
|
+
|
191
|
+
<h2 className={utilStyles.headingLg}>Blog</h2>
|
192
|
+
|
193
|
+
<ul className={utilStyles.list}>
|
194
|
+
|
195
|
+
{allPostsData.map(({ id, date, title }) => (
|
196
|
+
|
197
|
+
<li className={utilStyles.listItem} key={id}>
|
198
|
+
|
199
|
+
<Link href={`/${id}`}>
|
200
|
+
|
201
|
+
<a>{title}</a>
|
202
|
+
|
203
|
+
</Link>
|
204
|
+
|
205
|
+
<br />
|
206
|
+
|
207
|
+
<small className={utilStyles.lightText}>
|
208
|
+
|
209
|
+
<Date dateString={date} />
|
210
|
+
|
211
|
+
</small>
|
212
|
+
|
213
|
+
</li>
|
214
|
+
|
215
|
+
))}
|
216
|
+
|
217
|
+
</ul>
|
218
|
+
|
219
|
+
</section>
|
220
|
+
|
221
|
+
</Layout>
|
222
|
+
|
223
|
+
)
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
```
|
228
|
+
|
229
|
+
|
230
|
+
|
103
231
|
# エラー内容
|
104
232
|
|
105
233
|
|
106
234
|
|
107
|
-
```
|
235
|
+
```error
|
108
236
|
|
109
237
|
Server Error
|
110
238
|
|
111
|
-
|
239
|
+
Error: Error serializing `.allPostsData[0]` returned from `getStaticProps` in "/".
|
240
|
+
|
241
|
+
Reason: `object` ("[object Promise]") cannot be serialized as JSON. Please only return JSON serializable data types.
|
112
242
|
|
113
243
|
|
114
244
|
|
115
245
|
This error happened while generating the page. Any console logs will be displayed in the terminal window.
|
116
246
|
|
117
|
-
Source
|
118
|
-
|
119
|
-
.next/server/pages/index.js (26:34) @ <unknown>
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
24 | const repoUrl_tmp = `https://api.github.com/repos/satorun082/article/contents/${id}.md`
|
124
|
-
|
125
|
-
25 | const response_tmp = fetch(repoUrl_tmp)
|
126
|
-
|
127
|
-
> 26 | const file_tmp = response_tmp.json()
|
128
|
-
|
129
|
-
| ^
|
130
|
-
|
131
|
-
27 | const fileContents = base64.decode(file_tmp.content)
|
132
|
-
|
133
|
-
28 |
|
134
|
-
|
135
|
-
29 | // Use gray-matter to parse the post metadata section
|
136
|
-
|
137
247
|
Call Stack
|
138
248
|
|
249
|
+
isSerializable
|
250
|
+
|
251
|
+
file:///mnt/c/Users/minolab/Desktop/nextjs-blog/node_modules/next/dist/lib/is-serializable-props.js (64:15)
|
252
|
+
|
253
|
+
<unknown>
|
254
|
+
|
255
|
+
file:///mnt/c/Users/minolab/Desktop/nextjs-blog/node_modules/next/dist/lib/is-serializable-props.js (56:24)
|
256
|
+
|
257
|
+
Array.every
|
258
|
+
|
139
|
-
|
259
|
+
<anonymous>
|
260
|
+
|
140
|
-
|
261
|
+
isSerializable
|
262
|
+
|
141
|
-
|
263
|
+
file:///mnt/c/Users/minolab/Desktop/nextjs-blog/node_modules/next/dist/lib/is-serializable-props.js (54:23)
|
264
|
+
|
142
|
-
|
265
|
+
<unknown>
|
266
|
+
|
267
|
+
file:///mnt/c/Users/minolab/Desktop/nextjs-blog/node_modules/next/dist/lib/is-serializable-props.js (46:66)
|
268
|
+
|
269
|
+
Array.every
|
270
|
+
|
271
|
+
<anonymous>
|
272
|
+
|
273
|
+
isSerializable
|
274
|
+
|
275
|
+
file:///mnt/c/Users/minolab/Desktop/nextjs-blog/node_modules/next/dist/lib/is-serializable-props.js (43:39)
|
276
|
+
|
143
|
-
|
277
|
+
Object.isSerializableProps
|
144
|
-
|
278
|
+
|
145
|
-
|
279
|
+
file:///mnt/c/Users/minolab/Desktop/nextjs-blog/node_modules/next/dist/lib/is-serializable-props.js (66:12)
|
146
|
-
|
280
|
+
|
147
|
-
|
281
|
+
Object.renderToHTML
|
282
|
+
|
283
|
+
file:///mnt/c/Users/minolab/Desktop/nextjs-blog/node_modules/next/dist/server/render.js (430:97)
|
284
|
+
|
285
|
+
runMicrotasks
|
286
|
+
|
287
|
+
<anonymous>
|
148
288
|
|
149
289
|
```
|
150
290
|
|
1
題目の変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Next.jsにおける
|
1
|
+
Next.jsにおける外部APIの使用
|
test
CHANGED
File without changes
|