I’m trying to build an alphabetized index for all the authors listed on my site. Currently, authors whose first names have the same letter are getting duplicate entries:
{% assign people = site.data.book-data | sort: 'author' %}
<ul class="people-index-entries">
{% for p in people %}
<li class="index-entry">
<h2 id="{{ p.author | slice: 0 }}" class="index-heading">{{ p.author | slice: 0 }}</h2>
<a href="{{ site.baseurl }}/reviews/{{ p.name}}">{{ p.author }} – {{ p.title }}</a>
</li>
{% endfor %}
</ul>
I’m trying to find a way to get authors listed under a single letter. I was wondering if this might be possible with a where
filter – something along the lines of:
{% assign A = site.data.book-data | where: "author", "" %}
Is it possible to have a filter inside a filter? That is, could I do something like:
{% assign A = site.data.book-data | where: "author", "{{ entry.author | slice: 0 == A }}" %}
Not sure if I’m on the right track here, so any suggestions welcome. Here is an example of an entry in my data file:
- name: cusk-outline
title: Outline
author: Rachel Cusk
thumbnail: cusk-outline.jpg
publisher: Faber & Faber
pub-date: 3rd May, 2018
extents: 256pp.