Create an author index where duplicate values are nested

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 = | sort: 'author' %}
<ul class="people-index-entries">
  {% for p in people %}
  <li class="index-entry">
    <h2 id="{{ | slice: 0 }}" class="index-heading">{{ | slice: 0 }}</h2>
    <a href="{{ site.baseurl }}/reviews/{{}}">{{ }} – {{ p.title }}</a>
  {% endfor %}

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 = | where: "author", "" %}

Is it possible to have a filter inside a filter? That is, could I do something like:

{% assign A = | where: "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.

did you get it to work? your link looks like it is correct but there isn’t very many people so it may not be showing the problem.

Sounds like you would need an outer loop to do the letter, and then an inner loop inside that to do the people. That said I am not quite sure what the outer loop would look like.

sorry, i was meant to update the post. basically, i cheated by adding an index: [letter] key/value pair to each entry in the data set, then using a group_by filter to nest each entry with the same index value under the letter headings. sorry if that doesn’t make a whole lot of sense, but you can see the commit here.