Get all tags from document type

I'm having a Nuxt project where I use Prismic CMS.
I need to get all the tags from a specific document type

example: get all tags from "blog-post" document type or get all tags from "project" document type.

In the documentation I could not find how to query to my needs.
I tried with this query but I get all the tags from the API, including tags I dont need.

async fetch() { this.filters = await this.$prismic.api.tags }

Is there a way to write a query to receive the tags only who can be found in given document type.

Hi Martin,

Welcome to the community!

The only way to get the tags for a given custom type would be to query all documents of that type:

Then you would need to iterate through the documents and add the tags to and array.

1 Like

I was hoping for some query, but your solution should work also nice.
Thank you for feedback.

1 Like

Yeah normally if your doing an extra query like this you might be worried about performance, but given Nuxt.js's static deployment capabilities this shouldn't be an issue.

A good idea for this might be to do the query for these tags in the vuex store so that the query is done once as is available globally.

Let us know if you need anything else.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.