I have a group of different content types that I am trying to display in chronological order all together. Here's the page:
Currently, the only way I'm able to order the different content types chronologically together is like this:
@posts = api.query(
[ Prismic::Predicates.any("document.type", ["analysis", "data_viz", "blog", "news", "report" ]) ],
{
"page" => page,
"pageSize" => (9),
"orderings" => "[document.first_publication_date desc]"
}
)
Each content type has a field called "release_date" that allows the editor to set the "date" of the post. For the individual index pages for each type of content (e.g. news, analysis, blog, etc. I'm able to order them by release date like this:
@posts = api.query(
[ Prismic::Predicates.any("document.type", ["blog" ]) ],
{
"page" => page,
"pageSize" => 9,
"orderings" => "[my.blog.release_date desc]",
"after" => @hero_post_id
}
)
But I would like to also order them by release_date on the page that contains all content types (BailoutWatch • Tracking Coronavirus Stimulus to Fossil Fuels.).
I tried this:
@posts = api.query(
[ Prismic::Predicates.any("document.type", ["analysis", "blog", "data_viz", "news", "report" ]) ],
{
"pageSize" => 1,
"page" => 1,
"orderings" => "[my.analysis.release_date desc, my.blog.release_date desc, my.data_viz.release_date desc, my.news.release_date desc, my.report.release_date desc]",
"ref" => ref
}
)
But, all that does is loop through all of the document types that I list first, display them in chronological order, then goes onto the second document type displays them chronologically, etc.
I'm doing this in Rails. Is my only option to collect all of the documents from each document type in an API call, then manually sort them by "release_date" in Ruby?