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-discourse-topic-list

v0.0.3

Published

Source topic lists from the Discourse discussion forum platform and transform it into Gatsby nodes.

Downloads

7

Readme

Logo of gatsby-source-discourse-topic-list-logo

npm version npm downloads

gatsby-source-discourse-topic-list helps you source topic lists from the Discourse discussion forum platform and transform it into Gatsby nodes.

In addition to the topic list provided by the Discourse api, the plugin also fetches the raw text for each topic.

Getting Started

  1. Install the package with yarn or npm

yarn add gatsby-source-discourse-topic-list

  1. Add to plugins in your gatsby-config.js
module.exports = {
    plugins: [
        {
            resolve: "gatsby-source-discourse-topic-list",
            options: {
                url: "https://my-discourse-server.com"
                endPoint: 'top.json',
            }
        }
    ]
};

Options

| Name | Type | Description | | :-------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | url | object or string | Required. Url of your Discourse installation as a string. If you have two different APIs for development and production, define an object with the keys production and development. | | endPoint | string | Required. Any Discourse API endpoint returning a topic_list.| | rootKey | string | Optional. Name your API.|

Example Discourse API endpoints

Latest topics in a category:

options: {
    url: "https://meta.discourse.org"
    endPoint: 'c/1.json',
}

Latest topics in a category, filtered by tag:

options: {
    url: "https://meta.discourse.org"
    endPoint: 'tags/c/bug/1/pr-welcome.json',
}

Top topics in a category:

options: {
    url: "https://meta.discourse.org"
    endPoint: 'c/support/6/l/top.json',
}

See the Discourse API documentation for a full list of endpoints.

Example result

Note the added raw field containing the full unprocessed post topic text.

{
  "users": [
    {
      "id": 0,
      "username": "string",
      "avatar_template": "string"
    }
  ],
  "topic_list": {
    "can_create_topic": true,
    "draft": {},
    "draft_key": "string",
    "draft_sequence": 0,
    "for_period": "string",
    "per_page": 0,
    "topics": [
      {
        "id": 0,
        "title": "string",
        "fancy_title": "string",
        "slug": "string",
        "raw": "The full unprocessed topic text in markdown format", 
        "posts_count": 0,
        "reply_count": 0,
        "highest_post_number": 0,
        "image_url": {},
        "created_at": "string",
        "last_posted_at": "string",
        "bumped": true,
        "bumped_at": "string",
        "unseen": true,
        "last_read_post_number": 0,
        "unread": 0,
        "new_posts": 0,
        "pinned": true,
        "unpinned": {},
        "visible": true,
        "closed": true,
        "archived": true,
        "notification_level": 0,
        "bookmarked": true,
        "liked": true,
        "views": 0,
        "like_count": 0,
        "has_summary": true,
        "archetype": "string",
        "last_poster_username": "string",
        "category_id": 0,
        "pinned_globally": true,
        "posters": [
          {
            "extras": "string",
            "description": "string",
            "user_id": 0
          }
        ]
      }
    ]
  }
}

Multiple Sources? Multiple Instances!

If you would like to fetch multiple endpoints in your project, just instantiate the plugin multiple times. Just be sure to set a different rootKey for every instance.

Credits

This plugin builds on the excellent gatsby-source-custom-api by Andreas Faust. 🙏

Contributing

Every contribution is very much appreciated. Feel free to file bugs, feature- and pull-requests.

❤️ If this plugin is helpful for you, star it on GitHub.