While I'm able to pass variable via pageContext to GraphQL on all template based pages ( which use createPage function), I'm not able to pass/modify the context for pages which are part of src/page.
(虽然我能够通过pageContext将变量传递给所有基于模板的页面(使用createPage函数)上的GraphQL,但是我无法传递/修改属于src / page的页面的上下文。)
Consider this home page : src/pages/index.js
(考虑此主页:src / pages / index.js)
//want to pass dynamic value to $today
const IndexPage = ( {data, pageContext} ) => {
console.log(pageContext); // prints "isCreatedByStatefulCreatePages: true"
return (
<Layout />
)};
export default IndexPage;
export const Query = graphql`
offers( where : { day: $today})
{
..fields
}
`;
ask by Shatiz translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…