gatsby-source-local-git

npm MIT build

A Gatsby source plugin for sourcing data into your Gatsby application from your local git repository. The plugin enables gatsby sites to include meta data about their own git repository at build time.

You can find a running example here: https://using-gatsby-source-local-git.netlify.app/

Missing a feature? Please create an issue (or even a pull request).

Install

npm install --save gatsby-source-local-git

How to use

// In your gatsby-config.js
module.exports = {
  plugins: [`gatsby-source-local-git`],
}

Sources of the example are available at examples/using-gatsby-source-local-git/

How to query

The plugin creates Commit, Tag, Branch and Author nodes.

:warning: Please be aware that CI platforms might use an optimized strategy to fetch your git repository. Make sure to fetch all history for branches and tags depending on your needs.

Latest commit hash

{
  gitCommit(latest: { eq: true }) {
    hash
  }
}

Latest tag name

{
  gitTag(latest: { eq: true }) {
    name
  }
}

Only tag names including a dot will be considered (like v1.2.3 or 1.2 but not newest-feature).

Current Branches

{
  gitBranch(current: { eq: true }) {
    name
  }
}

Authors

{
  allGitAuthor(sort: { fields: name }) {
    nodes {
      name
      email
    }
    totalCount
  }
}