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

131
Visualizações
Implementing Previous Post & Next Post in a Next.js Contentful Blog?

I've been looking for an answer to this all over. Most of the people I have asked have shown me pagination examples, but that's not what I want. Even the question asked on here didn't help either

I have a Next.js site and I am using GraphQL to get my posts. I have it set up so that the resulting URL for the detail page of a post is blog/[category]/[slug]/

I want to have a link to the Previous Post and Next Post at the end of the posts to facilitate better navigation through the blog.

Here are the queries I have for loading the detail page:

To get all the posts:

{
  articleCollection(order:publishedAt_DESC){
    total
    items{
      title
      slug
      excerpt
      publishedAt
      category{
        categorySlug
        title
      }
      series{
        title
      }
      body{json}
    }
  }
}

To get a post by the slug:

query getArticle($slug: String!) {
  articleCollection(where: {slug: $slug}) {
    items {
      title
      slug
      excerpt
      publishedAt
      category {
        categorySlug
        title
      }
      series {
        title
      }
      illustration {
        url
      }
      body {
        json
      }
    }
  }
}

Could anyone please direct me to what I have to do:

  1. How do I modify the queries I have?
  2. Will I need to make additional queries to achieve previous and next? If so, how would those look like?

I am completely stumped on this

Thank you.

about 4 years ago · Juan Pablo Isaza
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