Is there an easy way to fetch all of the tags for a document type? In my case, I have a blog with various different document tags on each post, and I would like to find a way to fetch all of those tags for all of the posts to make a category selection system.
And to be able to get all the existing tags inside of your repo you just need to save the initial response of your endpoint, e.g https://your-repo-name.cdn.prismic.io/api/v2 (to get the correct endpoint for your project go to your repository settings / API & Security and select your technology to find the right endpoint), this response holds important metadata info about your repository, like all the Custom type names, all languages and of course all tags.
Thank you for the quick response. Unfortunately, I do not believe those solutions will work for me. I am using Prismic’s default tagging system, however I cannot query for a specific tag because I do not know what it is yet. The client can enter virtually any type of tag for a document, and I need to somehow get all of the tags in the system.
I can provide a specific example:
I have 3 documents, each with the type of post. Each post is tagged with the following, however in Nuxt I do not know this until I fetch the documents as a whole.
Post #1:TravelFood
Post #2:BeautyTravel
Post #3:FoodBeautyAdvice
In the above example, an easy solution would be to query the articles, and then parse the tags from them to create a list of tags. However, in my situation, there can be hundreds of articles, with virtually any tag, so it does not make sense to query the articles for the tags. I am wondering if there is a way to query the tags separately.
Yes, you can get all the tags that exist inside your repository, separately. As mentioned before, you can query the API, without any predicates, just the response from the endpoint itself will give you access to all existing tags.
See this example, here, before querying my Blog home singleton as normal, I’m saving the tags in a variable