As detailed in another thread about project, collaboration, and tree architecture, I have a primary content type — a glossary term definition.
One of my objectives for front matter in that project is to serialize out certain data values from HTML so collaborators (e.g. copywriters) who are not comfortable in lots of markup can more easily work with the content. Content that needs marked up in ways Markdown fails to do.
But, I’m not skilled with Jekyll and Liquid enough to figure out what I’m trying to do.
One example is dealing with authors & affiliations.
# Relevant, default front matter in term.md
---
collaborators:
-
who: "First Last"
affiliation: "Entity Name"
affiliation_url: "URL"
...
Contributing authors add their own front matter values. The first contributor (usually the person starting the initial file from an available template) simply changes the default values for their own details. The next contributor would copy the four lines and creating a second array:
# Author data for 2 contributors on term.md
collaborators:
-
who: "Jackie Jones"
affiliation: "JJ Enterprises"
affiliation_url: "URL"
-
who: "Pat Stewart"
affiliation: "Pat Stewart Media"
affiliation_url: "URL"
...
Btw, I’m not sure if that front matter is correct, or if it should look like this:
# Author data for 2 contributors on term.md
collaborators:
- who: "First Last"
affiliation: "Entity Name"
affiliation_url: "URL"
- who: "First Last"
affiliation: "Entity Name"
affiliation_url: "URL"
...
But when I ran it through YAML Lint validator, it corrected it to the former.
Anyway, the associated markup is kept in an include file instead of the term.md file, primarily to help keep the .md files a little more streamlined; I just want writers focusing on paragraphs, and not even seeing the tedious markup blocks):
<!-- Associated markup in /_includes/authors.html -->
<section>
<ul>
<li><<???>><sup><<???>></sup></li>
</ul>
<ol>
<li><sup><<???>></sup><a href="<<???>>"><<???>></a></li>
</ol>
</section>
The regions marked as <<???>>
are part of the Liquid I need to figure out…
- For each new contributor’s added to the front matter in a term.md file, a new author/affiliation pair of list items should be returned in the include output:
- The author list (
ul
) needs to get thewho
key value in eachli
. - the affiliation list (
ol
) needs to get theaffiliation
andaffiliation_url
key values in eachli
.
- The author list (
- The two instances of
<sup><<???>></sup>
need to be filled with a numeral beginning with1
, and increasing sequentially with each additionalli
added to list.
And, of course, this markup is inserted in term.md via a Liquid include tag, for which the structure needed I’m not entirely certain, indicated by parameter=var_name
:
<!-- Liquid include tag in term.md -->
{% include authors.html parameter=var_name %}
The problem is I don’t know how to add the necessary Liquid in authors.html, and pass that data to the include tag in the term.md file.
Because there are arrays in the front matter, I’m expecting some kind of loop needs used in the include markup:
<section>
{% for <<something>> in <<something_else>> %}
...
{% endfor %}
</section>
And I think each instance of sup
can be handled like this, where for each iteration through the array, the second assign
tag takes the previous value of {{counter}}
and adds 1
to it.
<ul>
{% assign counter = 1 %}
<li>... <sup>{{counter}}</sup></li>
{% assign counter = counter | plus:1 %}
<ol>
{% assign counter = 1 %}
<li><sup>{{counter}}</sup> ... </li>
{% assign counter = counter | plus:1 %}
And the li
in each list type needs some kind of iterative processing too, perhaps like this:
...
<ul>
{% for <<this>> in <<that>> %}
<li><<???>>...</sup></li>
{% endfor %}
...
<ol>
{% for <<this>> in <<that>> %}
<li><sup> ... <a href="<<???>>"><<???>></a></li>
{% endfor %}
...
Then altogether looking like this, roughly:
<!-- Hypothetical Liquid in /_includes/authors.html -->
<section>
{% for <<something>> in <<something_else>> %}
<ul>
{% for <<this>> in <<that>> %}
{% assign counter = 1 %}
<li><<???>><sup>{{counter}}</sup></li>
{% assign counter = counter | plus:1 %}
{% endfor %}
</ul>
<ol class="affiliations nomark">
{% for <<this>> in <<that>> %}
{% assign counter = 1 %}
<li><sup>{{counter}}</sup> <a href="<<???>>"><<???>></a></li>
{% assign counter = counter | plus:1 %}
{% endfor %}
</ol>
{% endfor %}
</section>
But that’s as much as I’ve been able to guess. I tried plugging different things into the holes, but it was like shooting bats in the dark with a blindfold on.
Can anyone help me with the needed Liquid structure?