如何在Gatsby中添加Facebook评论插件?
我正在使用Gatsby创建一个博客网站.我对Gatsby/React非常陌生.我需要有关Gatsby的Facebook评论插件的一些文档.
I'm creating a blog site using Gatsby. I am very very new to Gatsby/React. I need some documentation about the facebook comment plugin for Gatsby.
谢谢.
如果您的意思是使用Facebook的Graph API检索Facebook注释,该API提供 gatsby-source-facebook
,您可以按以下步骤将其安装到Gatsby网站中:
If you mean retrieving Facebook comments using Facebook's Graph API, which provides comments, you may be able to achieve that with gatsby-source-facebook
, which you can install as follows into your Gatsby site:
npm install --save gatsby-source-facebook
然后,通过将其添加到gatsby-config.js
来配置源插件:
Then, configure the source plugin by adding this to 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模式.
When you execute gatsby develop
and navigate to the provisioned local environment, such as http://localhost:8000
, you should be able to explore your GraphQL schema using GraphiQL at http://localhost:8000/___graphql
.