A git contributors plugin for Eleventy static site generator. The plugin returns a array of Git contributors for a page.
Install in project directory by running:
npm install --savedev eleventy-plugin-contributorsIn your Eleventy config file (defaults to .eleventy.js) include the plugin :
const getContributors = require('eleventy-plugin-contributors');
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(getContributors);
}The contributorplugin can be customised via the following options:
const getContributors = require('eleventy-plugin-contributors');
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(contributors, {
commits: 200, // the maxmium number of commits to include
repo: __dirname // location of the repo
});
}Now you can use the getContributors filter in your templates, to return an array of contributor records for a given file containing the git settings for authorName and authorEmail.
For example the following Nujucks markup will list the contributors for the current page:
{% set contributions = page.inputPath | getContributors -%}
{% for contributor in contributions -%}
- {{contributor.authorName}} {{ contributor.authorEmail}}
{% endfor %}MIT.