Merge pull request #164 from ForkAwesome/contributor-badge

Updates automatically the number of contributors in the README file.
This commit is contained in:
Julien Deswaef 2019-02-16 16:25:38 -05:00 committed by GitHub
commit ad6b42da71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -4,7 +4,7 @@
### {{ site.forkawesome.tagline }}
[![npm](https://img.shields.io/npm/v/fork-awesome.svg?style=flat&colorB=CB3837)](https://www.npmjs.com/package/fork-awesome)
[![All Contributors](https://img.shields.io/badge/all_contributors-112-orange.svg?style=flat-square)](CONTRIBUTORS.md)
[![All Contributors](https://img.shields.io/badge/all_contributors-{{ page.total_contributors }}-orange.svg?style=flat-square)](CONTRIBUTORS.md)
[![JSDeliver](https://data.jsdelivr.com/v1/package/npm/fork-awesome/badge)](https://www.jsdelivr.com/package/npm/fork-awesome)
[![CDNJS](https://img.shields.io/cdnjs/v/fork-awesome.svg?style=flat-square)](https://cdnjs.com/libraries/fork-awesome)
[![Build Status](https://travis-ci.org/ForkAwesome/Fork-Awesome.svg?branch=master)](https://travis-ci.org/ForkAwesome/Fork-Awesome)

View File

@ -0,0 +1,17 @@
##
# Generate an all-contributors badge with the number of contributors
require "json"
module Jekyll
class AllContributors < Generator
def generate(site)
all_contributors_rc = File.read(File.join(Dir.pwd, '.all-contributorsrc'))
all_contributors = JSON.parse(all_contributors_rc)
total_contributors = all_contributors['contributors'].length
readme = site.pages.detect {|page| page.name == 'README.md-nobuild'}
readme.data['total_contributors'] = total_contributors
end
end
end