如何在Gatsby中添加facebook评论插件?

问题描述 投票:1回答:1

我正在使用Gatsby创建一个博客站点。我对Gatsby / React非常新。我需要一些关于Gatsby的facebook评论插件的文档。

提前致谢。

reactjs facebook-javascript-sdk gatsby
1个回答
0
投票

如果您的意思是使用提供comments的Facebook的Graph API检索Facebook评论,您可以使用gatsby-source-facebook实现这一点,您可以将以下内容安装到您的Gatsby网站:

npm install --save gatsby-source-facebook

然后,通过将此插件添加到gatsby-config.js来配置源插件:

  plugins: [
    {
      resolve: `gatsby-source-facebook`,
      options: {
        places: [`${facebookPageID}`], // Can be either a numeric ID or the URL ID
        params: {
          fields: 'hours, posts { message, created_time }', // See Facebooks API to see what you can query for
        },
        key: process.env.FACEBOOK_GRAPH_TOKEN, // You will need to create a Facebook application and go through review in order to get an API token.
      },
    },
  ],

当您执行gatsby develop并导航到配置的本地环境(例如http://localhost:8000)时,您应该能够使用http://localhost:8000/___graphql上的GraphiQL探索GraphQL模式。

© www.soinside.com 2019 - 2024. All rights reserved.