Fairly new to Prismic so this took me a while to figure out. The method is very straightforward:
Once you make a relationship between two types (ie, products and categories), you can use this query to get products by a specific category:
const products = await this.$prismic.api.query(
this.$prismic.predicates.at('my.product.category', 'category_id')
)
The category id is found in the category document (it looks something like: X_uidsfsdFKHF2
). Per the documentation, that is the ONLY way to make this query work. You can't use uid
or type
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…