2

通过这种请求,使用插件从ContentfulGraphQLgatsby-source-contentful中提取帖子数据,寻找访问帖子发布日期 (post.sys.publishedAt) 或 updatedAt 的方法!

 {
  contentfulPost(id: { eq: 'postId' }) {
   --> publishedAt ?
   title
   image {
    responsiveResolution(width: 500, height: 500) {
      src
      srcSet
      height
      width
    }
  }

}

4

1 回答 1

2

source-contentful 插件不包含sysGraphQL 模式中的属性。它只包括字段和 id。作为一种解决方法,您可以添加一个包含日期的字段,它将在 graphQL 中可供您使用。

我希望这有帮助

编辑 - - - - - - - -

我刚刚提交了一个 PR,将这些选项添加到 gatsbyjs https://github.com/gatsbyjs/gatsby/pull/2398 您现在可以访问updatedAtcreatedAt属性。

于 2017-10-04T11:32:15.877 回答