【发布时间】:2021-10-30 23:33:07
【问题描述】:
我正在尝试从 graphql 查询中呈现站点的元数据,该查询在 graphql 操场上运行良好,但我什至无法 console.log 数据,当我尝试将其注销时,它给了我一个整数安慰? 因此,我只是尝试使用 gatsby 文档在屏幕上呈现它并收到此错误:32:41 error 'data.site.siteMetadata.description' is missing in props validation
const IndexPage = ({ data }) => {
return (
<Layout>
<SEO
keywords={[`gatsby`, `tailwind`, `react`, `tailwindcss`]}
title="Home"
/>
<div className="container mx-auto flex flex-col md:flex-row items-center">
<div className="flex flex-col w-full lg:w-1/2 justify-center items-start pt-12 pb-24 lg:-px-12">
<h3
style={{ fontFamily: "Permanent Marker" }}
className="text-4xl py-2 lg:-mx-32 font-title"
>
Meet the world’s only dedicated analytic platform for active
nutrition.
</h3>
<h4
style={{ fontFamily: "Montserrat" }}
className="text-2xl py-10 lg:relative right-32"
>
Nutrition Integrated supplies companies with the data, tools and
insights to understand the moving landscape and make smarter
decisions.
</h4>
</div>
<div className="w-full lg:w-hero lg:py-6 text-center lg:-mr-12 relative lg:left-24">
<img
className="fill-current text-black "
src={image}
alt="image"
></img>
</div>
<h2> {data.site.siteMetadata.description}</h2>
</div>
</Layout>
);
};
export const query = graphql`
query MyQuery {
allContentfulLandingPage {
edges {
node {
heroTitle {
heroTitle
}
heroBody {
raw
}
}
}
}
}
`;
export default IndexPage;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
【问题讨论】:
标签: javascript reactjs graphql gatsby