Customize the Contributor Table
By default, the All Contributors app and CLI create a contributor table that displays seven contributors per row. Each contributor has its own cell in the row containing three items: a 100x100-pixel avatar (which is the contributor’s GitHub profile picture), the contributor’s name (or username if they have no name listed in their GitHub profile), and a row of emojis representing different contribution types they have been credited for. You change the way the table is rendered in the .all-contributorsrc configuration file. After you have made changes to that file, the Bot will apply the new settings the next time it regenerates the table.
How to change the contributor table layout
Заголовок раздела «How to change the contributor table layout»You can modify three table layout options (contributors per row, avatar size, and how contributors are sorted) by adjusting the values in the .all-contributorsrc configuration file. In the following example, the table is modified to show five contributors per row and 80-pixel avatars; contributors are also sorted alphabetically:
{ "contributorsPerLine": 5, "imageSize": 80, "contributorsSortAlphabetically": true}Without contributorsSortAlphabetically, contributors appear in the order they were added. With it, the table is sorted alphabetically by the person’s full display name (the name field in .all-contributorsrc, which usually comes from their GitHub profile). It is not sorted by first name or last name separately. If someone has no name, their GitHub username (login) is used instead.
Add a footer link
Заголовок раздела «Add a footer link»If you want to provide a link in the last row of the contributor table with instructions for contributors to add their own contributions, set linkToUsage to true. This link is hidden by default unless you add it as a setting.
{ "linkToUsage": true}Add your own contribution types
Заголовок раздела «Add your own contribution types»If you are using the CLI, you can use the types option to add your own contribution types, modify the emoji used to represent the contribution, or modify the symbol, description, or link for emoji types that already exist. Each key in the JSON structure is the name of the contribution type. Below you add a new type called mapping. The value lets you specify the symbol for that type (often an emoji), a description, and a link. The link value is optional. You can use it as a template for the address the emoji points to, and it can use symbol, description, contributor, and options:
{ "types": { "mapping": { "symbol": "🗺️", "description": "Mapping", "link": "https://example.org/maps?author=<%= contributor.login %>" } }}Customize the contributors table and badge
Заголовок раздела «Customize the contributors table and badge»You can change how All Contributors writes the contributors table and badge into your README file (or any other file listed in files). You can:
- Change the badge color
- Remove avatars or resize them
- Change how names and emojis are laid out
- Restyle the table
To make these changes, add the following options to .all-contributorsrc:
contributorTemplate: the cell for one contributorwrapperTemplate: the table that holds all the cellsbadgeTemplate: the badge between the badge markers
These options only change the code that is written to create the contributor table. They don’t change how the Bot replies in issues or pull requests.
Change the badge color
Заголовок раздела «Change the badge color»The badge color is part of the badge URL. The example below changes the badge to blue. You can use any color name or hex code (without the #):
{ "badgeTemplate": "[](#contributors-)"}The badge is a shields.io image, so you can also change style=flat-square to flat, for-the-badge, and other standard shields.io styles. Here are a few examples with different colors and styles (the number is only a sample). Each block shows the markdown first, then how that badge renders:
Default orange, flat-square:
[](#contributors-)Blue, flat-square:
[](#contributors-)Bright green, flat:
[](#contributors-)Purple, for-the-badge:
[](#contributors-)Hex color ee8449, plastic:
[](#contributors-)Remove the avatar
Заголовок раздела «Remove the avatar»By default, each contributor looks like this:
<a href="https://github.com/jsmith"> <img src="https://avatars.githubusercontent.com/u/1?v=4" width="100px" alt="Jane Smith"/> <br /><sub><b>Jane Smith</b></sub></a><br />💻 📖To show only the name and emojis, add this to .all-contributorsrc:
{ "contributorTemplate": "<a href=\"<%= contributor.profile %>\"><b><%= contributor.name %></b></a> <%= contributions %>"}The result:
<a href="https://github.com/jsmith"><b>Jane Smith</b></a> 💻 📖Start from the default cell
Заголовок раздела «Start from the default cell»To make small changes, copy the default template and edit it. This template reproduces the default cell. It must stay on one line in JSON:
{ "contributorTemplate": "<a href=\"<%= contributor.profile %>\"><img src=\"<%= contributor.avatar_url %>\" width=\"<%= options.imageSize %>px\" alt=\"<%= contributor.name %>\"/><br /><sub><b><%= contributor.name %></b></sub></a><br /><%= contributions %>"}Template reference
Заголовок раздела «Template reference»For full control, contributorTemplate, wrapperTemplate, and badgeTemplate replace the default HTML and badge text that All Contributors writes into your README (or other files listed in files). Each template is a string with \<%= value %> placeholders, and each option has its own placeholders:
| Опция | Placeholders | What it replaces |
|---|---|---|
contributorTemplate |
contributor, contributions, options |
The cell of one contributor |
wrapperTemplate |
bodyContent, tableFooterContent |
The table around all rows |
badgeTemplate |
contributors |
The badge between the badge markers |
What the placeholders hold:
contributor: thelogin,name,avatar_url, andprofileof the personcontributions: the row of emoji links, already formattedoptions: your.all-contributorsrcconfigurationbodyContent: all the contributor cellstableFooterContent: the table footercontributors: the list of contributors
Templates can’t use any value that isn’t listed here. For example, the badge template doesn’t know your repository name, so a badge for a particular repository has to spell the name out. Update the badge shows this.
