Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

if a team member is removed from the team her/his names disappears from the author section of an article #216

Open
ff6347 opened this issue Jun 4, 2020 · 0 comments
Assignees

Comments

@ff6347
Copy link
Collaborator

ff6347 commented Jun 4, 2020

@dnsos I can take this one, but I thought it might be a good point for you to get familiar with liquid templating logic.

The snippet that does the name lookup in all the team members is this one

{%- assign team = site.team_en -%}
{%- else -%}
{%- assign team = site.team_de -%}
{%- endif -%}
{%- for author in page.authors -%}
{%- for member in team -%}
{%- if member.uid == author -%}
<a href="{{member.url}}" class="project-header__meta-column__item">{{member.name}}</a>
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}

We add to the frontmatter of a page a list of authors

like this one https://github.com/technologiestiftung/lab-site/blob/master/source/projects/fisbroker-to-qgis/de/index.md#L16-L17

If the list matches the names of the team members it takes the real name from the team members and adds it as markup.

Two things I didn't anticipate when writing this.

  1. What happens when the name does not match?
  2. What happens if a Team member leaves the team?

For 1. we can just write the actual name and insert it leaving out the <a hef=""></a> tag.
For 2. I guess it would be nice to have a list of alumnis we can link to.


So my suggestion is creating a new collection called _alumni with the following data

---
name: Duffy Duck
uid: duffy-duck
link: https://example.com
---

We make no EN/DE difference and if we don't find a team member with that ID we also look up in the alumni collection. If still don't find anyone there we just use the text that was added in there.

Instead of running two loops it might be better to merge the two collections (team_(en/de) + alumni). Merging those objects seems not to be possible in liquid. The snippet below takes another approach. The variable site.documents holds all collections, pages, posts etc. We only have to filter for those we want

This snippet should get you started (should you choose to accept this mission)

{% for item in site.documents %}
<!-- we build the collection name based on the pages variables -->
{% assign team_collection_name = "team_" | append: page.lang %}
<!-- we filter for only the ones in the wanted collections -->
  {% if item.collection == team_collection_name or item.collection == 'alumni'  %}
  <!--{{ item | jsonify }} -->
  <!-- dont use the term "url" for storing the link to a alumni. The property url odes exists on all of the documents -->
  {{ item.name }}
  {% endif %}
{% endfor %}

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

No branches or pull requests

2 participants