我是一个有用的助手,可以为您翻译文本。
有没有任何想法是什么在阻塞?
我第一次测试 Gatsby 和 GraphQl,并尝试使用一个简单的示例...
当我尝试通过 GraphQl 请求在我的布局中显示标题时,出现了以下错误: Uncaught TypeError: Cannot read property 'site' of undefined
这是我的布局:
import React from 'react'
import { graphql } from 'gatsby'
export default ({ children, data }) =>
<div style={{margin: 'auto', maxWidth: 760}}>
<h2>{data.site.siteMetadata.title}</h2>
{children}
<footer>
Copyright blablb abolajoa.
</footer>
</div>
export const query = graphql`
query LayoutQuery {
site {
siteMetadata {
title
}
}
}
`
我的gatsby-config.js文件:
module.exports = {
siteMetadata: {
title: `Hardcoders`
},
plugins: [
{
resolve: 'gatsby-plugin-typography',
options: {
pathToConfigModule: 'src/utils/typography.js'
}
},
]
}
以下是该项目的配置:
"dependencies": {
"gatsby": "^2.0.0",
"gatsby-plugin-typography": "^2.2.0",
"react": "^16.5.1",
"react-dom": "^16.5.1",
"react-typography": "^0.16.13",
"typography": "^0.16.17",
"typography-theme-github": "^0.15.10"
}
有没有任何想法是什么在阻塞?