Last active
July 2, 2024 21:02
-
-
Save TeamDijon/686913fdd775534206279030ca461409 to your computer and use it in GitHub Desktop.
Some snippets on how to use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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