Query by Tag

This page gives you a couple of examples of how to query documents by their tags. If you want to query all of the documents with a certain tag, then you just need to specify the document.tags.

Query by a Certain Tag

Here is an example of a query of all the documents with the tag "Featured".

Copy
this.$prismic.client.query(
  this.$prismic.Predicates.at('document.tags', ['Featured'])
).then((response) => {
  // response is the response object, response.results holds the documents
});

Query all of Multiple Tags

This example shows how to query all of the documents with either the tag "Tag 1" or "Tag 2" by using the any predicate.

Copy
this.$prismic.client.query(
  this.$prismic.Predicates.any('document.tags', ['Tag 1', 'Tag 2'])
).then((response) => {
  // response is the response object, response.results holds the documents
});

How to get a list of all tags in your repository

When you query the api endpoint of your repository, you can receive many different properties from the repository such as the ref, Custom Types, languages, tags, etc.

To receive all the the tags from the API data, simply query the API as shown here.

Copy
const apiEndpoint = "http://your-repo-name.prismic.io/api/v2";
this.$prismic.api(apiEndpoint).then((result) => {
  const tags = result.tags;
  console.log(tags);
});