我在盖茨比中有这个页面:
import React from 'react'
import Link from 'gatsby-link'
import IntroPartial from '../partials/themes/intro'
export default class ThemeTemplate extends React.Component {
render(){
const theme = this.props.pathContext.theme
console.dir(this.data)
return (
<div>
<h1>{theme.name}</h1>
<IntroPartial theme={theme} />
</div>
)
}
}
export const pageQuery = graphql`
query ThemeQuery($theme: String){
allMarkdownRemark(
filter: { frontmatter: { themes: { in: [$theme] } } }
){
edges{
node{
frontmatter{
title
themes
}
html
}
}
}
}
`
假设我提供了$theme
. 我如何提供价值$theme
?我想将其设置为this.props.pathContext.theme.slug
.
文档似乎暗示某些变量应该可以工作,但我不确定如何添加我自己的。