I am creating a metaobject that holds recipes. I want to be able to filter the recipes by ingredients and category. I also want the list to be paginated. From my research, it looks like the best practice is to make an ajax call to a backend app that then calls the graphql api to retrieve the entries and return it to the frontend. The frontend js would then build the html.
I’d prefer to be able to pass in a url parameter to the page and use a liquid template to create the page, /recipes?ingredient=salmon&category=fish&page=3. Is this possible? From everything I have read, url parameters can’t be read in liquid without a hack because the code is compiled on the server? I don’t understand what that means, do they mean cached and not compiled? why are the url parameters not passed as an attribute on the request object?
What are the SEO implications to using an ajax call to build the recipe lists? What is the best way to solution this?
I’d like to do something like this with the filters applied:
{% assign sortable_metaboject = shop.metaobjects.recipes.values %}
{% assign sorted_metaobject = sortable_metaboject | sort_natural: 'date_created' %}
{% paginate shop.metaobjects.recipes.values by 10 %}
{% for entry in sorted_metaobject %}
{% render 'metaobject-image-with-text-date', recipe: entry, image_first: image_first, show_button: true %}
{% endfor %}
{{ paginate | default_pagination }}
{% endpaginate %}