Nuxt/Content surround for previous and next

412 Views Asked by At

I cannot retrive prev and next article with nuxt content.

in my slug page I have this code:

async asyncData({ $content, params }) {
  const article = await $content('onstep', params.slug).fetch();

  const [prev, next] = await $content('onstep')
    .only(['title', 'slug', 'order'])
    .sortBy('order', 'desc')
    .surround(params.slug)
    .fetch();

  return {
    article,
    prev,
    next
  };
},

but prev and next returning null, oneother things I don't understand, is the

.surround(params.slug)

Why is used params.slug???

If I use postman to http://localhost:3000/_content/onstep?only=title&only=slug&only=order I get the list of my article, in my case I use a tag called order to order how the content should be seen.

In my project I need to use trailingSlash to true, but if I console.log params.slug is without trailingSlash

any suggestions?

1

There are 1 best solutions below

0
On

my fault, and one day gone...

Having some problems with google crawler I addes the / to any slug, so nuxt will try to find my-slug but in all articles the slug are my-slug/ edited all the slug and now work perfectly