Skip to content

Gatsby source plugin to use a disqus XML export as a data source

License

Notifications You must be signed in to change notification settings

chadly/gatsby-source-disqus-xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gatsby Disqus XML Source Plugin

A Gatsby source plugin to use a Disqus XML export as a data source.

Given a Disqus XML export, this source plugin will make threads & comments available to query via GraphQL. This will allow you to statically render comments and not include the Disqus embed code on your site. This can be useful if you are trying to migrate away from Disqus but you don't want to lose your existing comments. Or it could be useful if you want to server-render your comments for SEO purposes and replace the comment div with the Disqus embed code at runtime.

Install

yarn add gatsby-source-disqus-xml

or

npm install gatsby-source-disqus-xml

How to use

In gatsby-config.js:

module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-disqus-xml`,
      options: {
        filePath: "my_disqus_export.xml"
      },
    },
  ],
}

Query for Nodes

You can query for all threads:

{
  allDisqusThread {
    edges {
      node {
        threadId
        link
        comments {
          id
          parentId
          author {
            name
            username
          }
          createdAt
          message
        }
      }
    }
  }
}

or for a specific thread:

{
  query CommentThreadById($threadId: String!) {
    disqusThread( threadId: { eq: $threadId }) {
      threadId
      link
      comments {
        id
        parentId
        author {
          name
          username
        }
        createdAt
        message
      }
    }
  }
}

About

Gatsby source plugin to use a disqus XML export as a data source

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published