I want to create a list of recent authors for a blog I'm developing using Jekyll.
I'm taking the list of recent authors and looking up each item in a yml data sheet I've set up that lists each author and their bio, name and email etc.
I'm able to extract the information I want but when it renders in the browser it's in between <code>
tags.
The problem bit is
{% assign recent_leader = site.data.leaders[dedupped_leader] %}
{{ recent_leader.name }}
{{ recent_leader.bio }}
The assign statement seems to cause the entire loop contents to drop into a code block.
How do I get rid of the <code>
tags? I'm wondering if there's just a comma out of place somewhere or ...
Here is the rest of the code for the page.
{% comment %}First loop captures leaders from the last three months {% endcomment %}
{% for post in site.posts %}
{% capture postDateSeconds %}{{post.date | date: "%s"}}{% endcapture %}
{% capture siteTimeMinusTwelveWeeks %}{{site.time | date: "%s" | minus: 7260000}}
{% endcapture %}
{% if postDateSeconds >= siteTimeMinusTwelveWeeks and post.date <= site.time %}
{% capture indexes %}{{ indexes | append: forloop.index | append: "," }}{% endcapture %}
{% capture leaders %}{{ leaders | append: post.leader | append: "," }}{% endcapture %}
{% endif %}
{% endfor %}
{% comment %}Split the captured loop into its own array {% endcomment %}
{% assign leaders_array = leaders | split: "," %}
{% comment %} initialise a new array for dedupped list{% endcomment %}
{% assign dedupped_leaders = "" %}
{% comment %} if the leaders name is in the new array already remove it. Then add the name. This makes sure the name is on the list just once. {% endcomment %}
{% for leader in leaders_array %}
{% if dedupped_leaders contains leader %}
{% assign leader_and_comma = leader | append: "," %}
{% capture dedupped_leaders %}{{dedupped_leaders | remove_first: leader_and_comma }}{% endcapture %}
{% endif %}
{% capture dedupped_leaders %}{{dedupped_leaders | append: leader | append: ","}}{% endcapture %}
{% endfor %}
{% comment %}Split the captured loop into its own array {% endcomment %}
{% assign dedupped_leaders_array = dedupped_leaders | split: "," %}
{% for dedupped_leader in dedupped_leaders_array %}
{% assign recent_leader = site.data.leaders[dedupped_leader] %}
{{ recent_leader.name }}
{{ recent_leader.bio }}
{% endfor %}
{% assign recent_leader = site.data.leaders[dedupped_leader] %}
{{ recent_leader.name }}
{{ recent_leader.bio }}
If you do this in a markdown file, it will output code block ( see kramdown documentation )
If you don't want code block, do :
no line break after a not indented line
{% assign recent_leader = site.data.leaders[dedupped_leader] %}
{{ recent_leader.name }}
{{ recent_leader.bio }}
or two space indentation
{% assign recent_leader = site.data.leaders[dedupped_leader] %}
{{ recent_leader.name }}
{{ recent_leader.bio }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.