Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
Referencing GraphQL variable used in query in Gatsby template?

I am aggregating all posts that have a certain tag in it's tag list:


export const Search = graphql`
  query SearchResults($tag: String = "") {
    allMarkdownRemark(filter: { frontmatter: { tags: { in: [$tag] } } }) {
      nodes {
        frontmatter {
          title
          date
        }
      }
    }
  }
`

The query works great, but I want to also be able to dynamically show the tag that is being queried for. How can I pass this information through?

For example: Searching results for tag: Java which would be the value inside $tag in the graphql query.

I tried to pull from the URL, but it's rendered in node, so I don't have access to the window object and it felt a bit hacky anyway.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I got it. Passing in props.pageContext gives you access to the contextual information passed in via gatsby-node.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda