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-plugin-git

v0.0.1-4

Published

Gatsby plugin which checkout a repository e.g. to populate content

Downloads

271

Readme

gatsby-plugin-git

Plugin for fetching a single revision of a remote repository into gatsby source tree.

Keeping the code and content together in a single revision history might not always be a solution (e.g. content is used in multiple sites). This plugin allows to separate the content from your code, while keeping a clear relation between the code and the content, thus, avoiding error due to inconsistencies between code and content.

Install

npm install --save gatsby-plugin-git

or

yarn add gatsby-plugin-git

How to use

Hide a folder from your git revision history.

/content

Then configure the plugin to fetch a specific commit from your remote repository.

module.exports = {
  plugins: [
    // You can have multiple instances of this plugin
    // to fetch multiple 

    {
      resolve: 'gatsby-plugin-git',
      options: {

        // remote name, default to origin
        remote: 'origin',

        // SHA1 revision to fetch and checkout
        revision: '7beed15dd03e03f9f9a183ed3b53f0e51f6dbbd7',

        // url of the repository to fetch
        url: `https://github.com/gatsbyjs/gatsby.git`,

        // folder in which to put the repository
        path: `${__dirname}/content/my-repo`,
      }
    },
  ]
}

:warning: This plugin will checkout the specified revision, discarding your current branch tip, even if the revision is the head of your current branch. It will result in a detached HEAD. So you might not want to use this on your development environement, as you would have to constantly checkout back to your branch to commit new revisions.

It is specifically intended for automated deployment, to fetch a single revision of a repository (not the full history) and check it out. So you might want to condition this plugin to run only on deployment. And for your development environement, you can manually put the repository in your local content folder, e.g. using submodules, or symbolic links.

Simplest example

As an example, I forked gatsby-starter-default and added this plugin to fetch some random repo: https://github.com/etnbrd/gatsby-starter-default

All the code needed to use the plugin can be found in this commit: https://github.com/etnbrd/gatsby-starter-default/commit/e263f16da23e3c887930ffdbed826296a07799d9 (It doesn't include the condition for deployment only, though, as that would depend on your environements)

It fetches the repo toddmotto/public-apis, and sources it with gatsby-source-filesystem. As a result, the file README.md should be available in your graph.