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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gatsby-source-pleroma

v1.2.1

Published

gatsby-source plugin for Pleroma federated social network feed

Readme

gatsby-source-pleroma

Source plugin for pulling data into Gatsby from a single user's Pleroma feed.

Installation guide

  • Install Gatsby
  • Install plugin with npm or yarn
    • npm install gatsby-source-pleroma --save
    • yarn add gatsby-source-pleroma
  • Update your gatsby-config.js file with the following:
module.exports = {
 siteMetadata: { ... },
 plugins: [
   ...,
   {
     resolve: 'gatsby-source-pleroma',
     options: {
       instance: 'https://pleroma.example.site', // required
       userId: 1, // required,
       pages: 2 // optional
     }
   }
 ]
}

Options

When requiring the plugin, there are several options that must be passed down and a few that can be optionally passed down, in order to determine whose data you are including and exactly how much.

  • instance (required): The url (no trailing slash!) of the instance to which the user belongs. e.g. if you're signed up for pleroma at the main https://pleroma.site, you would use that exact string.
  • userId (required): The integer id or username of the user for whom the feed is being fetched. When visiting a user profile on Pleroma, you can find this id in the url e.g. a userId of 1 is indicated by https://pleroma.site/users/1. This also goes for userId of 'foggy', which would be https://pleroma.site/users/foggy.
  • pages (optional | default: 1): If you would like to paginate from more than just the latest 20 posts in a pleroma feed, pass this option.

Usage

Pleroma data from the given user's feed will be included as allPleromaPost in Gatsby's graphQL infrastructure.

As an example, a very large query that utilized a majority of the keys from a single post object from Pleroma's twitter API would look like:

query GetPleromaPosts {
  allPleromaPost(sort: {fields: [statusnet_conversation_id], order:DESC}) {
    edges {
      node {
        statusnet_conversation_id
        activity_type
        created_at
        external_url
        fave_num
        id
        in_reply_to_status_id
        is_local
        is_post_verb
        repeat_num
        repeated
        statusnet_conversation_id
        summary
        uri
        visibility
        text
        statusnet_html
        user {
          profile_image_url_https
          screen_name
          statusnet_profile_url
        }
        attachments {
          url
          empty
        }
      }
    }
  }
}

This query would be sorted on the field statusnet_conversation_id in a descending fashion and would make all of the above key values available in the component which queried them in this.props.data.edges.node.

A Note About Attachments

Every time this plugin runs at build time, it is dynamically generating a graphql schema: what you are able to query is at the mercy of what the source plugin pulls in and builds the schema with. This is powerful because we do not have to explicitly define a schema ahead of time and only get what we want. But it is also a huge pain because if we are expecting something and we do not get it from any individual post, it won't be in the schema, and declarations involving that item will crash our build.

Attachments are a prime example of this.

In order to thwart this, I've shimmed a placeholder attachment into the build process for any item which is fetched but lacks any attachments. The upside is, in just a line-and-a-half of code, I've undercut a nasty problem. Without this code, anytime you do the following:

query somethingWithAttachmenets {
  ...
    ...
      ...
        attachments {
          url
        }
}

If all you sourced were empty arrays, then your code is going to yell at you: it never built a node called "attachment" with knowledge of a "url" field.

The downside of this is, we have to live with a slightly weird result: you will never get no attachments. You will always get at least one, and often, that one will be an empty attachment with a field empty set to true.

At the moment, this is the best we can do. I'm unsatisfied with the complexity involved in other ways of dealing with this issue. Just keep in mind that if you want to check if you have no attachments, you need to check the truthiness of attachments[0].empty.