Skip to content

Instantly share code, notes, and snippets.

@TeamDijon
Last active July 2, 2024 21:02
Show Gist options
  • Save TeamDijon/686913fdd775534206279030ca461409 to your computer and use it in GitHub Desktop.
Save TeamDijon/686913fdd775534206279030ca461409 to your computer and use it in GitHub Desktop.
Some snippets on how to use
{% comment %}
If you have questions regarding the blog/article list interface, see :
https://gist.github.com/TeamDijon/15684d1bef3c4bb5ca9dfd8a9381a156
As always, with collections/blogs/articles, mind the potential conflicts with pagination
For the article handle source, I usually go with a "ricthext" setting using unordered list.
From this, I can retrieve the data and store everything in an array before using it on the following snippets of code
{% endcomment %}
{% # Here, we render article cards from a list of article handles %}
{% for article_handle in article_handle_list %}
{% liquid
assign blog_handle = article_handle | split: '/' | first
assign article_blog = blogs[blog_handle]
%}
{% render 'article-card', blog: article_blog, article: articles[article_handle]
{% endfor %}
{% # Here, we get a sorted list of recent posts from multiple blogs %}
{% liquid
assign recent_post_list = ''
for blog_handle in blog_handle_list
assign associated_blog = blogs[blog_handle]
if associated_blog == null
continue
endif
assign blog_post_list = associated_blog.articles
if recent_post_list == blank
assign recent_post_list = blog_post_list
else
assign recent_post_list = recent_post_list | concat: blog_post_list
endif
endfor
if recent_post_list != blank
assign recent_post_list = recent_post_list | sort: 'published_at' | reverse
endif
%}
{% for recent_post in recent_post_list %}
{% assign associed_blog_handle = recent_post.handle | split: '/' | first %}
{% render 'article-card', blog: blogs[associated_blog_handle], article: recent_post %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment