Gatsby:从 JSON 创建多个页面
Gatsby: creating multiple pages from JSON
我正在尝试使用 Gatsby 从 JSON 数据
创建多个 HTML 页面
我正在尝试弄清楚如何使用 gatsby-node.js
gatsby develop
→ 确定
gatsby build
→ 失败
这是我的 gatsby-node.js
,它坏了
const path = require("path")
const quotesList = path.resolve("src/constants/quotesList")
const Quotes = path.resolve(`src/components/Quotes`)
exports.createPages = ({ actions }) => {
const { createPage } = actions
return new Promise(
resolve => {
resolve(
quotesList.forEach(
(quote, id) => {
createPage(
{
path: `/quotes/${id}`,
component: Quotes,
},
)
},
),
)
},
)
.catch(
e => console.error("Fail createPages", e),
)
}
最后是
WebpackError: Invariant Violation: Minified React error #61; visit https://reactjs.org/docs/error-decoder.html?invariant=61 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
我应该如何更改它才能加载 JSON 数据并从中生成多个页面(大约一百个)?
问题是 dangerouslySetInnerHTML
prop
的格式不正确
我正在尝试使用 Gatsby 从 JSON 数据
创建多个 HTML 页面我正在尝试弄清楚如何使用 gatsby-node.js
gatsby develop
→ 确定gatsby build
→ 失败
这是我的 gatsby-node.js
,它坏了
const path = require("path")
const quotesList = path.resolve("src/constants/quotesList")
const Quotes = path.resolve(`src/components/Quotes`)
exports.createPages = ({ actions }) => {
const { createPage } = actions
return new Promise(
resolve => {
resolve(
quotesList.forEach(
(quote, id) => {
createPage(
{
path: `/quotes/${id}`,
component: Quotes,
},
)
},
),
)
},
)
.catch(
e => console.error("Fail createPages", e),
)
}
最后是
WebpackError: Invariant Violation: Minified React error #61; visit https://reactjs.org/docs/error-decoder.html?invariant=61 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
我应该如何更改它才能加载 JSON 数据并从中生成多个页面(大约一百个)?
问题是 dangerouslySetInnerHTML
prop