diff --git a/_includes/news-post-index.html b/_includes/news-post-index.html new file mode 100644 index 0000000..d8b5953 --- /dev/null +++ b/_includes/news-post-index.html @@ -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" }} diff --git a/news.md b/news.md index 9a9451b..4b7122c 100644 --- a/news.md +++ b/news.md @@ -18,10 +18,14 @@ layout: news-post The following is an example of a news post's content: -## Title -Content + Introduction -— Name + ### Subheading + Content + ### Subheading + Content + + — Author Name --> {% comment %} @@ -30,9 +34,10 @@ Content {% for post in site.posts limit: 3 %}