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-multigitmarkdown

v1.0.6

Published

Gatsby Source plugin to read from multiple md file sources across different repositories

Downloads

9

Readme

gatsby-source-multigitmarkdown

The plugin is a source plugin that helps in pulling content of MD files from different github repositories. It can also be configured to get content from same repository but different md files. Each md file content and it's configured metadata is created as a node in an array of nodes.

Dependencies

The project used the following libraries

  • axios (for making the http call to fetch content)
  • remark (for parsing the contents of md files into a HTML)

How to install

To install the plugin you may run the following command

For NPM:

   npm -i gatsby-source-multigitmarkdown

For Yarn:

    yarn add gatsby-source-multigitmarkdown

To use the plugin, add the following into the gatsby-config.js

module.exports = {
  siteMetadata: siteMetadata,
  plugins: [
    {
      resolve: `gatsby-multigitsource-plugin`,
      options: {
        pages: [{
          repo: "arunmadhavan-g/config-driven-ui",
          file: "README.md",
          title: "Building a Config Driven UI in React - Part 1",
          publishedOn: "2019-11-24T12:39:18.088Z",
          author: "Arun Madhavan",
          tags: ["reactjs", "javascript", "ui"],
          description: "Part 1 of a 2 part blog, where I share my experiences with development of a configuration driven UI to build their executive dashboard",
        }]
      }
    }]
}

Available options

| Options | Description | | --- | --- | |pages.repo| the username and repository name part of the repo URL | |pages.file | The name of the md file | |pages.title | The Page title | |pages.publishedOn | The published date of the page | |page.author | author's name | |page.tags | tags associated with the page | |page.description | A short Description of what the page does |

The above mentioned options would be exposed as part of the graphql node. Information passed in pages.repo and pages.file will be utlilised for fetching the md file content.

When do I use this plugin?

The motivation behind building this plugin was to aggregate content from multiple github repositries into a single blog platform This helps in adding pages with sources coming from different public repositories md file into a single place.

Examples of usage

Add the following code with proper options to your gatsby-config.js

module.exports = {
  siteMetadata: siteMetadata,
  plugins: [
    {
      resolve: `gatsby-multigitsource-plugin`,
      options: {
        pages: [{
          repo: "arunmadhavan-g/config-driven-ui",
          file: "README.md",
          title: "Building a Config Driven UI in React - Part 1",
          publishedOn: "2019-11-24T12:39:18.088Z",
          author: "Arun Madhavan",
          tags: ["reactjs", "javascript", "ui"],
          description: "Part 1 of a 2 part blog, where I share my experiences with development of a configuration driven UI to build their executive dashboard",
        }]
      }
    }]
}

The data can be queried using the following graphQL query

query MyQuery {
  allMultiGitSource {
    edges {
      node {
        pageInfo {
          author
          content
          description
          pagePath
          publishedOn
          tags
          title
        }
      }
    }
  }
}

For example we can query the data in gatsby-node.js and createPages for each of the returned information as shown below

exports.createPages = async ({ graphql, actions: { createPage } }) =>
  (await graphql(`
  query MyQuery {
    allMultiGitSource {
      edges {
        node {
          pageInfo {
            author
            content
            description
            pagePath
            publishedOn
            tags
            title
          }
        }
      }
    }
  }`)).data.allMultiGitSource.edges.map(x => x.node.pageInfo).forEach(page => {
    createPage({
      path: `/${_.camelCase(page.title)}`,
      component: require.resolve("./src/templates/page-template.js"),
      context: { page },
    })
  })

How to query for data

The data is made available as part of allMultiGitSource node. Contents can be queried using a query like below.

query MyQuery {
  allMultiGitSource {
    edges {
      node {
        pageInfo {
          author
          content
          description
          pagePath
          publishedOn
          tags
          title
        }
      }
    }
  }
}