Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jekyll/jekyll-avatar
A Jekyll plugin for rendering GitHub avatars
https://github.com/jekyll/jekyll-avatar
avatars github github-pages jekyll jekyll-plugin
Last synced: 4 days ago
JSON representation
A Jekyll plugin for rendering GitHub avatars
- Host: GitHub
- URL: https://github.com/jekyll/jekyll-avatar
- Owner: jekyll
- License: mit
- Created: 2016-01-10T17:50:55.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2022-04-15T10:28:49.000Z (almost 3 years ago)
- Last Synced: 2024-11-16T20:11:35.362Z (2 months ago)
- Topics: avatars, github, github-pages, jekyll, jekyll-plugin
- Language: Ruby
- Size: 110 KB
- Stars: 91
- Watchers: 14
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: History.markdown
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Jekyll Avatar
*A Jekyll plugin for rendering GitHub avatars*
[![CI](https://github.com/jekyll/jekyll-avatar/actions/workflows/ci.yml/badge.svg)](https://github.com/jekyll/jekyll-avatar/actions/workflows/ci.yml)
Jekyll Avatar makes it easy to add GitHub avatars to your Jekyll site by specifying a username. If performance is a concern, Jekyll Avatar is deeply integrated with the GitHub avatar API, ensuring avatars are cached and load in parallel. It even automatically upgrades users to Retina images, when supported.
## Installation
Add the following to your site's `Gemfile`:
```ruby
gem 'jekyll-avatar'
```And add the following to your site's `_config.yml` file:
```yaml
plugins:
- jekyll-avatar
```
Note: If you are using a Jekyll version less than 3.5.0, use the `gems` key instead of `plugins`.## Usage
Simply add the following, anywhere you'd like a user's avatar to appear:
```
{% avatar [USERNAME] %}
```With `[USERNAME]` being the user's GitHub username:
```
{% avatar hubot %}
```That will output:
```html
```### Customizing
You can customize the size of the resulting avatar by passing the size argument:
```
{% avatar hubot size=50 %}
```That will output:
```html
```### Passing the username as variable
You can also pass the username as a variable, like this:
```
{% assign user="hubot" %}
{% avatar {{ user }} %}
```Or, if the variable is someplace a bit more complex, like a loop:
```
{% assign employees = "alice|bob" | split:"|" %}
{% for employee in employees %}
{% avatar user=employee %}
{% endfor %}
```### Lazy loading images
For pages showing a large number of avatars, you may want to load the images lazily.
```liquid
{% avatar hubot lazy=true %}
```This will set the `data-src` and `data-srcset` attributes on the `` tag, which is compatible with many lazy load JavaScript plugins, such as:
* https://www.andreaverlicchi.eu/lazyload/
* https://appelsiini.net/projects/lazyload/### Using with GitHub Enterprise
To use Jekyll Avatars with GitHub Enterprise, you must set the `PAGES_AVATARS_URL` environmental variable.
This should be the full URL to the avatars subdomain or subpath. For example:
* With subdomain isolation: `PAGES_AVATARS_URL="https://avatars.github.example.com"`
* Without subdomain isolation: `PAGES_AVATARS_URL="https://github.example.com/avatars"`