【发布时间】:2021-02-28 22:02:26
【问题描述】:
我有包含不同 URL 的页面。现在我从所有页面获取所有数据,但我需要为不同的 URL 获取不同的数据。我试图过滤它,但得到错误。那么如何检查 url='something' 是否需要查询呢?
import React from "react";
import { StaticQuery, graphql } from "gatsby";
import ArticleMfo from "../components/articleMfo";
const Products = () => (
<StaticQuery
query={graphql`
query MyQuery {
allContentfulAllPages(filter: {link: {eq: $MYURL}}) {
edges {
node {
mfo {
__typename
... on ContentfulBank {
id
text
limit
rate
term
link
logo {
title
file {
url
}
}
}
}
}
}
}
}
`}
render={data => (
<Container className="container">
{data.allContentfulAllPages.edges.map(({ node }, i) => (
<div>
{node.mfo.map(mfos => (
<ArticleMfo key={mfos.id} content={mfos} />
))}
</div>
))}
</Container>
)}
/>
);
export default Products
【问题讨论】:
-
错误是什么? :)
-
我不记得了。我尝试了很多方法。你能告诉我如何查询它的正确方法吗?我最近才开始研究 react/gatsby。
标签: reactjs gatsby contentful