I have been trying for a few days now to query all the documents 1) of a specific custom type 2) with a specific value at data.mainTag.
Scenario:
I want to create a slice called "SimilarMainTag" that will display all the pages with the same MainTag value as the one currently displayed.
So in my custom type [uid].js (custom type=pillar_page), in my getStaticProps function, I am retrieving the page.data.maintag to compare it with all data.maintag of documents of type "pillar_page":
Attempt 1 & 2 fall.
I am not sure neither how to import "prismic". Am I supposed to use prismic.H or import Prismic from 'prismic-javascript'? none of them worked so far.
Would you be as kind as telling me what am I doing wrong?
I think this kind of filtering should interest a lot of people for SEO purposes.
That's correct. Since you're using a custom tagging system instead of the default one, the queries will be different.
In this case, you'll need to use fetchLinks or GraphQuery to get the data from the linked documents. You can find an example of this in our official Next docs, in the fetch data document:
It looks like this will just create an array of the length of categoryList.length in which every item is prismic.filter.at("my.category.uid", 'projekte'). I'm not sure what affect that will have on your query.
If you're trying to filter by category, you need to reference the linking property on the document and use the category's ID. It would be something like this: