Skip to content

Instantly share code, notes, and snippets.

@miyaoka
Last active December 18, 2017 20:15
Show Gist options
  • Save miyaoka/a7c9206a17ccec44b8aed4271fda52e6 to your computer and use it in GitHub Desktop.
Save miyaoka/a7c9206a17ccec44b8aed4271fda52e6 to your computer and use it in GitHub Desktop.
<ul class="actor-links">
{% assign post_actor_ids = site.posts | map: 'actor_ids' | join: ',' | split: ',' | sort %}
{% assign actor_and_count = '' | split: '.' %}
{% for actor in site.actors %}
{% assign count = 0 %}
{% for post_actor_id in post_actor_ids %}
{% if actor.actor_id == post_actor_id %}
{% assign count = count | plus: 1 %}
{% endif %}
{% endfor %}
{% include mkhash.inc actor = actor count = count %}
{% assign actor_and_count = actor_and_count | push: h %}
{% endfor %}
{% assign sorted_actor_and_count = actor_and_count | sort: 'count' %}
{% for item in sorted_actor_and_count reversed %}
{% assign actor = item.actor %}
<li class="actor-links__item">
<a href="{{ actor.url }}">
<img src="{{ actor.image_url | prepend:site.baseurl }}" alt="{{ actor.title }}" class="actor-image" width="80" height="80">
<br>
{{ actor.title }}
({{ item.count }})
</a>
</li>
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment