Hi garethredfern
I found your solution on pagination in nuxt content blog: Adding Pagination to a Nuxt Blog, it really helps a lot!
However I encountered 2 problems.
One is that the "getContent" method might return invalid data.
// use the % (modulus) operator to get a whole remainder
const lastPageCount = totalArticles % perPage;
When totalArticles % perPage == 0
, the lastPageCount
is 0
, which is not right, I suggest you change it to the following code
// use the % (modulus) operator to get a whole remainder
const lastPageCount = totalArticles % perPage == 0? perPage: totalArticles % perPage;
Problem number two is the <pagination/> component, in your article, you used Math.floor(this.total / this.perPage)
for totalPages
, actually this should be Math.ceil(this.total / this.perPage)
, and I saw that you have corrected this in the source code, but not in your article.
I would really appreciate it if you could modify your article. And thanks again for writing this amazing solution!