Having more than `role` and `description` in portrait component
sbbe2024 opened this issue ยท 5 comments
Checks
- I have searched the docs, existing issues, and existing discussions for answers first.
Link to your website repo
https://github.com/sbbecongresso/sbbecongresso.github.io
Version of Lab Website Template you are using
1.2.1
Description
Hello.
Regarding the members, I am aware that the description will override the role. However, I would like to know if there would be a way to keep two or more entries like NAME, ROLE & AFFILIATION for instance:
George Pacheco
Postdoctoral Researcher
University of Oslo
I did try to change the code to achieve such a result to no avail. I think it is somewhere in here:
{% if member.role or member.description %}
<span class="portrait-role">
{% assign type = site.data.types[member.role] %}
{% include icon.html icon=type.icon %}
<span>{{ member.description | default: member.role type.description member.affiliation }}</span>
Many thanks in advance, George.
Generally I would say please create an Discussion for this rather than an Issue, since it's not really a bug or feature request. But in this case I guess affiliation
might be a common need, so I'll take this as an opportunity to build it into the template. I'll also take this as an opportunity to clean up the portrait.html
source code, as there seem to be some leftover couplings that make things more confusing.
You are in the right area of the code but your Liquid syntax is invalid. If you want to have multiple default
fallbacks, you need to chain multiple | default:
pipes together. I think what you want is this:
member.description | default: member.affiliation | default: type.description
This will use the description
field from the member's .md
file, then use their affiliation
if that is not defined, then fallback to a global default description in _data/types.yaml
. Also, I think you don't want member.role
, because that's usually just a lower-case kebab-case short id like pi
, used to look up more details from a list.
However, if this is really what you want, why not just have your members put their university/affiliation as their description, if only one or the other can ever be shown?
Perhaps you really want affiliation to be shown in addition to the description, like this:
In that case, add the following right before the closing </span>
of <span class="portrait-text">
:
{% if member.affiliation %}
<span>{{ member.affiliation }}</span>
{% endif %}
One last important thing. Due to a limitation with Jekyll, you will need to add affiliation=d.affiliation
to the list.html
component, as described here:
https://greene-lab.gitbook.io/lab-website-template-docs/advanced/custom-components
Hello.
Thanks a lot for your swift reply.
I am sorry I posted it as an issue but I saw it as a new feature in the sense of making it possible to have more than just a role or description. For instance, it could be implemented that the user could add << besides role >> several descriptions to the same member: Description_1, Description_2, Description_3... what these descriptions would be would depend on the user: affiliation, age, team (...). So that is why I saw it as a feature request.
But very much for your solution -- it does work: https://sbbecongresso.github.io/Comiss%C3%A3o%20Organizadora/
The only thing I had to add was a space because they were ending up in the same line:
{% if member.role or member.description %}
<span class="portrait-role">
{% assign type = site.data.types[member.role] %}
{% include icon.html icon=type.icon %}
<span>{{ member.description | default: type.description }}</span>
<br> <!-- Add a line break here -->
{% if member.affiliation %}
<span>{{ member.affiliation }}</span>
{% endif %}
</span>
{% endif %}
Kind regards, George.
You needed the line break there because you put the affiliation inside the portrait role span. It more appropriately belongs under the portrait text span.
Sorry again for my mistake. I confirm that your modification does work.
No worries, I just wanted to clarify the difference. If you check back later, hopefully this will be added into the template and also the component will be a bit easier to customize.