gatsby-snipcart
gatsby-snipcart copied to clipboard
Filter by category
Hi great theme! Would you be able to point me tin the right direction as to how I would be able to sort/filter products by category? Thanks again
Hi, Are you looking to display items from different categories in different sections? You could easily add a 'category' to the frontmatter of each product markdown file and then filter your graphQL query on that?
allMarkdownRemark(filter: {frontmatter: {category: {eq: 'gluten-free'}}})
That would display only those with the category of 'gluten-free'.
If you want to programmatically generate pages for each category I suggest you take a look at the gatsby docs page on tags. Its designed with a blog in mind but it can easily be adapted to work for a category rather than tags.
Let me know if I can be of anymore help!