-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlatest-post.liquid
48 lines (33 loc) · 1.44 KB
/
latest-post.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{% comment %}
Show each of your store's most recent blog post, regardless
of which blog it came from.
Write out the handles of all your blogs in a semi-colon
separated list where it says {% assign blog_handles = "..." %}
{% endcomment %}
{% assign blog_handles = "handle-1;handle-2;handle-3" %}
{% assign blog_list = blog_handles | split: ';' %}
{% assign article_list = '' %}
{% for blog_handle in blog_list %}
{% for article in blogs[blog_handle].articles limit: 1 %}
{% capture article_list %}{{ article_list }}%%%{{ blog_handle }}@%{{ article.published_at }}{% endcapture %}
{% endfor %}
{% endfor %}
{% assign article_array = article_list | split: '%%%'%}
{% assign latest_date = '' %}
{% assign latest_blog = '' %}
{% for article_set in article_array %}
{% unless forloop.first %}
{% assign article_item = article_set | split: '@%' %}
{% if article_item[1] > latest_date %}
{% assign latest_blog = article_item[0] %}
{% assign latest_date = article_item[1] %}
{% endif %}
{% endunless %}
{% endfor %}
<article>
{% for article in blogs[latest_blog].articles limit: 1 %}
<h3><a href= "{{ article.url }}">{{ article.title }}</a></h3>
<p><span class="date" style="display: block;">Posted: <em>{{ article.published_at | date: "%B %d %Y" }}</em> in <a href="{{ blogs[latest_blog].url }}">{{ blogs[latest_blog].title }}</a></span></p>
<section>{{ article.excerpt_or_content }}</section>
{% endfor %}
</article>