【发布时间】:2020-03-13 07:20:59
【问题描述】:
我在 Netlify CMS 中使用 Gatsby,但在 Netlify CMS 中预览模板时遇到了问题。
有一个index page component 按预期工作。它从 markdown 和 frontmatter 中获取数据,并与
Netlify CMS 小部件和 featured posts 组件通过 useStaticQuery 钩子获取其数据。
但是,一旦我在 Netlify 管理员中转到 index page preview template,我就会得到:
Error: The result of this StaticQuery could not be fetched.
This is likely a bug in Gatsby and if refreshing the page does not fix it, please open an issue in https://github.com/gatsbyjs/gatsby/issues
useStaticQuery
./.cache/gatsby-browser-entry.js:1
> 1 | import React from "react"
2 | import PropTypes from "prop-types"
3 | import Link, {
4 | withPrefix,
View compiled
_default
./src/components/common/FeaturedPosts.js:1
> 1 | import React from 'react'
2 | import v4 from 'uuid'
3 | import { useStaticQuery, graphql } from "gatsby"
4 |
View compiled
▶ 28 stack frames were collapsed.
我的目标是从来自 Netlify CMS 和特色博客列表组件的 markdown 和 frontmatter 数据中呈现 homepage,该组件通过 Netlify Admin 中的 useStaticQuery 挂钩从 /posts 目录获取其数据。
复制repo可以找到here
【问题讨论】:
标签: javascript graphql gatsby netlify netlify-cms