Skip to content

Instantly share code, notes, and snippets.

@pkcpkc
Created October 24, 2023 10:10
Show Gist options
  • Save pkcpkc/57cc48e90796fdd955785146932e363a to your computer and use it in GitHub Desktop.
Save pkcpkc/57cc48e90796fdd955785146932e363a to your computer and use it in GitHub Desktop.
liquid-intersection
{% comment %}Input from article{% endcomment %}
{% assign articleTopics = "t3,t4,t5" | split: "," %}
{% assign articleAuthors = "a1,a2" | split: "," %}
{% comment %}This will come from user.topics, user.authors{% endcomment %}
{% assign userTopics = "t1,t3,t5" | split: "," %}
{% assign userAuthors = "a2,a4" | split: "," %}
{% for userTopic in userTopics %}
{% if articleTopics contains userTopic %}
{% assign topicsIntersection = topicsIntersection | concat: userTopic %}
{% endif %}
{% endfor %}
{% if topicsIntersection.size > 0 %}
Push-Thema: {{topicsIntersection.first }}
{% else %}
{% for userAuthor in userAuthors %}
{% if articleAuthors contains userAuthor %}
{% assign authorsIntersection = authorsIntersection | concat: userAuthor %}
{% endif %}
{% endfor %}
Push-Autor: {{authorsIntersection.first}}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment