Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesnt work with variables #61

Open
tblobaum opened this issue Mar 26, 2022 · 10 comments
Open

doesnt work with variables #61

tblobaum opened this issue Mar 26, 2022 · 10 comments

Comments

@tblobaum
Copy link
Contributor

{% avatar {{ page.author }} %} for some reason tries to load the avatar based on the name of the author instead of the username passed in

{{ page.author }} is tblobaum
tblobaum has name set as Thomas Blobaum in GitHub
{% avatar {{ page.author }} %} tries to load the avatar for "Thomas " instead of tblobaum

@benbalter
Copy link
Collaborator

@tblobaum see https://github.com/jekyll/jekyll-avatar#passing-the-username-as-variable for alternate ways to pass "complex" variables.

@tblobaum
Copy link
Contributor Author

@benbalter that's the part of the documentation I originally referenced. Unless I'm too dumb to figure it out it doesn't quite work.

@ashmaroli
Copy link
Member

@tblobaum Is your repository public? If yes, please provide the link to it and the URL of your webpage where you see the issue.
Thanks.

@tblobaum
Copy link
Contributor Author

The repository is public but I have since changed the code.

First of all, your example doesn't make sense.

{% assign user="hubot" %}
{% avatar {{ username }} %}

Why are you assigning user and then using username?

Secondly, I have narrowed down the issue. It seems that if I set author: tblobaum in the front matter and then try to use {% avatar {{ page.author }} %} it fails and loads the name from the GitHub account as a username to fetch the avatar with. For instance when page.author is tblobaum it tries to load an avatar for Thomas . I found out I can get avatars to work by only using them in an array. For some reason unknown to me, when placed in a loop of all site.authors the same code {% avatar {{ page.author }} %} loads the right avatar. I don't see why simply placing the code inside a loop of site.authors should change its behavior.

@ashmaroli
Copy link
Member

First of all, your example doesn't make sense.

Good catch! Its a typo! Would you be interested in submitting a pull request to correct it?


Regarding the main issue here, it needs some investigations. I'll look into it.

@ashmaroli
Copy link
Member

I've not been able to reproduce this.
I tested with a boilerplate site (wired to use jekyll-avatar-0.7.0) containing the following page:

---
author: tblobaum
---

{% avatar {{ page.author }} %}
{% avatar ashmaroli %}

It rendered as expected into below:
localhost_4000_test

Either I do not understand the issue or something is wrong at your end.
If former, please provide a reproducible repo.

@tblobaum
Copy link
Contributor Author

Repo is: https://github.com/tblobaum/thenewworldpost.com

If you clone the repo you first need to uncomment jekyll-avatar in the Gemfile and _config.yml (they are both at the bottom of the page) then you can run it with bundle install and then bundle exec jekyll serve then navigate to _layouts/post.html and paste at the top of the file somewhere {% avatar {{ page.author }} %} then navigate to the entertainment/2022/01/01/kylo-ren-of-star-wars-the-force-awakens-was-inspired-by-nazis.html or another post on the homepage of the website which has tblobaum as the author in frontmatter. If you open up _posts/entertainment/2015-11-28-kylo-ren-of-star-wars-the-force-awakens-was-inspired-by-nazis.markdown you can see in the frontmatter author: tblobaum yet the avatar being rendered is for the github usernamed Thomas

@ashmaroli
Copy link
Member

@tblobaum I have been able to reproduce the issue using your repo. (You forgot to tell me that I should clone gh-pages instead of master.. pfft! smh!).
Anyways, the issue seems to be differences between Jekyll 3 and Jekyll 4.
You should be able to use this plugin either by using Jekyll 3.9 via gem "jekyll", "~> 3.9" or by pointing the jekyll-avatar gem to this repository:

gem "jekyll", "~> 4.2.1"
gem "jekyll-avatar", github: "jekyll/jekyll-avatar"

@ashmaroli
Copy link
Member

Related: #59

@ashmaroli
Copy link
Member

Hi,
v0.8.0 has been released. Please upgrade and confirm if this issue has been resolved.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants