gatsby-snipcart icon indicating copy to clipboard operation
gatsby-snipcart copied to clipboard

Filter by category

Open marquez138 opened this issue 5 years ago • 1 comments

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

marquez138 avatar Jul 31 '19 20:07 marquez138

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!

issydennis avatar Aug 09 '19 10:08 issydennis