npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gatsby-source-twitter-threads

v1.0.9

Published

Source Twitter threads in Gatsby

Downloads

3

Readme

gatsby-source-twitter

Source plugin for pulling threads into Gatsby from Twitter Search API. Useful for creating blog posts out of Twitter threads.

Example

See gatsby-twitter-threads-demo as an example of creating blog posts using this plugin.

How to use

Install

yarn install gatsby-source-twitter-threads

Get API Access

To start using this plugin you have to create an App on the developer portal and then provide the consumer_key (API Key), consumer_secret (API Secret), and the handle (without the @) in the gatsby-config.js file:

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-twitter-threads`,
      options: {
        credentials: {
          consumer_key: "INSERT_HERE_YOUR_CONSUMER_KEY",
          consumer_secret: "INSERT_HERE_YOUR_CONSUMER_SECRET",
        },
        user: `my-twitter-handle`,
      },
    },
  ],
}
  • credentials: API Key and API Secret from Twitter Developer Portal.
  • user: Twitter handle for your account.

How to query your conversations using GraphQL

Get All Conversations/Threads

query GetAllConversations {
  allTwitterConversation {
    nodes {
      id
      text
    }
  }
}

Get Single Conversation/Thread

  query GetConversation($id: String!) {
    twitterConversation(id: {eq: $id}) {
      id
      text
    }
  }

Limitations

Currently, Twitter only allows searching the entire Tweet archive when the app is for "Academic Purposes." This will only provide the conversations from the past 7 days.

Potential Workaround

While this is not implemented in this package, a workaround to this limitation would be to fork the gatsby-node.js file and do the following:

  1. Ensure you have a database that can store the entire thread archive from this point going forward (and an API to interact with it).
  2. Before calling createNodes (after getting the latest threads), post the latest threads to the database (via a POST request).
  3. Then, fetch all the conversations from the database (via a GET request).
  4. Finally, call createNodes with the entire archive of threads (not just the latest ones returned by the Twitter client).