I am trying to create a related post feature for my blog.
Is there a way to loop through array of articles in my blog i.e. blog.articles
using the array of tags from the current article i.e. article.tags
to see if the blog.articles.tags contains any of the tag value in article.tags
and then return the array of articles that was filtered.
I check the when array filter and it is meant to search the condition for a string and not an array.
{%- assign normalized_article_tags = article.tags | join:"," | downcase | strip_html | split:"," -%}
{%- assign all_article_tags = blog.article.tags | join:"," | downcase | strip_html | split:"," -%}
{% assign blog_articles = blog.articles | where: all_article_tags contains normalized_article_tags %}
{%- for article in blog_articles -%}
{%- render 'article-related-post', article: article -%}
{%- endfor -%}
But the where condition is not working in this case.