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

[dev] Handling writers via YAML + JSON-LD #71

Open
wion opened this issue Apr 10, 2017 · 0 comments
Open

[dev] Handling writers via YAML + JSON-LD #71

wion opened this issue Apr 10, 2017 · 0 comments

Comments

@wion
Copy link

wion commented Apr 10, 2017

This is a challenge for people more skilled than myself with Jekyll, Liquid, and YAML.

We have a central YAML file where all collaborator data is stored (/_data/collaborators.yml). A given user's data in the file looks like this:

---
### This file provides people data for contributor attributions and linked data.
### The 'writer' key should be changed to 'true' if a person contributes copy to a definition.
-
  letnes_marit_:	
  name: "Marit Letnes"
  affiliation: "Marit Letnes Media SA"
  affiliation_url: "https://maritletnes.no"
  country: "Norway"
  writer: true
...
-
  wion_destry:
  name: "Destry Wion"
  affiliation: "Story Needle"
  affiliation_url: "http://storyneedle.com/"
  country: "India"
  writer: false
...
---

Ultimately the file will be used to output data in two locations:

  1. The glossary index page, where all collaborators will be listed
  2. The individual definition files where contributing writers will be listed

Situation 1

The first scenario is setup and working. In the index page markup, the following HTML and Liquid block calls the relevant data from the central collaborators.yml file, and CSS creates the presentation we want on the Glossary Index (a wrapping list of names, comma-separated):

<section class="contributors-index">
  <p>Contributions by:</p>
  <ul class="authors nomark">
    {% for collaborator in site.data.collaborators %}
      <li>{{ collaborator.name }} ({{ collaborator.country }})</li>
    {% endfor %}
  </ul>
</section>

The first scenario is easy because there's no need for author front matter in the index file. We want all collaborator names, so data is pulled for every collaborator from the central collaborators.yml file.

Situation 2

By contrast, the second scenario of extracting specific names from the total collaborators list and outputting them on the respective definition files is not as easy.

How it currently works is to add the data for the respective contributors to the front matter for that definition file, then create the include markup accordingly which looks like this:

<section class="contributors-definition">
    <ul class="authors nomark">
      {% for item in page.authors %}
        <li>{{ item.name }}<sup>{{ forloop.index }}</sup></li>
      {% endfor %}
    </ul>
    <ol class="affiliations nomark">
      {% for item in page.authors %}
        <li><sup>{{ forloop.index }}</sup><a href="{{ item.affiliation_url }}">{{ item.affiliation }}</a>, {{item.country}}</li>
      {% endfor %}
    </ol>
</section>

But that is needlessly redundant because the front matter in the local definition file is the same as the front matter stored in the central collaborators.yml file.

Ideal situation

Ideally, the front matter in each definition simply references the respective data in the central collaborators.yml file for writers indicated in the local front matter. So instead of duplicating all the lines of user data in the local front matter as it exists in the collaborators.yml file, we would simply have something like this, which references the names of people we want to pull data from in the central file:

writers: [letnes_marit, wion_destry]

Then alter the Liquid looping markup in the include file for each person identified in the local front matter.

The problem is I don't know what the Liquid looping markup should look like when the data is being funneled through the local front matter instead of being pulled directly from the central collaborators.yml file. It seems to me the local front matter is needed to filter the right names, but after that I'm not sure how the Liquid should be written.

Liquid/YAML/JSON-LD experts needed.

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

1 participant