Hi @tomrutgers
thanks for jumping in.
Not sure how best to share, the data is stored in DatoCMS
this is the graphQL output from the API explorer
Might also be helpful to know I am using the DATOCMS middleman gem to interact with the data
{
"data": {
"article": {
"topic": [
{
"title": "Business"
},
{
"title": "Web Design"
},
{
"title": "Web Advice"
}
]
},
"allArticles": [
{
"topic": [
{
"title": "Business"
},
{
"title": "Web Design"
},
{
"title": "Web Advice"
}
]
},
{
"topic": [
{
"title": "Web Advice"
},
{
"title": "Web Strategy"
},
{
"title": "Business"
},
{
"title": "Web Design"
}
]
},
{
"topic": [
{
"title": "Web Advice"
},
{
"title": "Web Design"
},
{
"title": "Web Strategy"
}
]
},
{
"topic": [
{
"title": "Web Advice"
},
{
"title": "Web Design"
},
{
"title": "Business"
}
]
},
{
"topic": [
{
"title": "CMS"
},
{
"title": "Web Advice"
}
]
},
{
"topic": [
{
"title": "Web Advice"
},
{
"title": "Web Project Management"
}
]
},
{
"topic": [
{
"title": "eCommerce"
},
{
"title": "Web Advice"
},
{
"title": "Business"
}
]
},
{
"topic": [
{
"title": "Web Design"
},
{
"title": "Web Project Management"
},
{
"title": "Web Development"
}
]
},
{
"topic": [
{
"title": "Web Design"
},
{
"title": "Web Advice"
},
{
"title": "Web Development"
}
]
},
{
"topic": [
{
"title": "Web Advice"
},
{
"title": "Web Project Management"
}
]
}
]
}
}
{
"data": {
"allTopics": [
{
"title": "Web Advice"
},
{
"title": "Web Design"
},
{
"title": "Web Strategy"
},
{
"title": "Business"
},
{
"title": "SEO"
},
{
"title": "Web Development"
},
{
"title": "eCommerce"
},
{
"title": "Logo Design"
},
{
"title": "Web Project Management"
},
{
"title": "CMS"
}
]
}
}
is this the kind of thing you are after?
My problem is with the correct syntax to use to filter the dataset against an array (the topics), and each article stores an array of topics
SO I want to loop through each article and look at the topic array and compare it to the topic variable within the loop
I’ll add my rb.config too that might help!
dato.tap do |dato|
dato.articles.each do |article|
proxy "/articles/#{article.slug}/index.html", "/templates/article.html",
locals: { article: article }
end
end
dato.tap do |dato|
dato.topics.each do |topic|
proxy "/articles/topics/#{topic.slug}/index.html", "/templates/topics.html",
locals: { topic: topic }
end
end
dato.tap do |dato|
paginate dato.articles.sort_by(&:date_published), "/articles", "/templates/articles.html", per_page: 6
end