Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda