Synthesize issue ID from posts array

This commit is contained in:
Spotlight 2022-09-04 02:58:52 -05:00
commit dcbc12c293
No known key found for this signature in database
GPG key ID: 874AA355B3209BDC
2 changed files with 34 additions and 5 deletions

View file

@ -0,0 +1,23 @@
{% comment %}
By default, we'll assume we haven't found the index.
{% endcomment %}
{% assign page_index = 'Unknown' %}
{%- for possible_post in site.posts -%}
{%- if possible_post.title == post.title -%}
{%- assign page_index = forloop.rindex -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{% comment %}
If we found an index, zero pad it, if necessary.
Thank you to https://stackoverflow.com/a/37453646 for this solution!
{% endcomment %}
{%- if page_index != 'Unknown' -%}
{%- assign page_index = page_index | prepend: '00' | slice: -2, 2 -%}
{%- endif -%}
Issue {{ page_index }} - {{ post.date | date: "%B %-d, %Y" }}