I am using a string to fetch data from the database I want to render the string conditionally if the title exists then I want to render a different string obviously I can do this
if(title){
const string = "this"
}else{
const string = "that"
}
But I have 5 variables and if I create the pair it creates at least 5! which is not feasible.
My requirements
If my title exists then
*[_type == "cases" && title match "${title}" && date <= "${date}"]{title,slug,description,country,state,district,date,mainImage{asset->{url}}}
If my title does not exist
*[_type == "cases" && date <= "${date}"]{title,slug,description,country,state,district,date,mainImage{asset->{url}}}