Article pagination frontend implementation

This commit is contained in:
Florian Sylvain
2023-01-19 02:30:01 +01:00
parent 94b42d7e34
commit a4ee8f90ff
4 changed files with 40 additions and 13 deletions
+4 -1
View File
@@ -2,6 +2,7 @@ package articles
import (
"fmt"
"math"
"net/http"
"os"
"strconv"
@@ -30,9 +31,10 @@ func getBuiltGetResponse(articles []Article, skip uint64, take uint64) map[strin
}
slicedArticles := articles[skip:normTake]
total := len(slicedArticles)
return map[string]any{
"content": slicedArticles,
"total": len(slicedArticles),
"total": total,
"pagination": map[string]any{
"skip": skip,
"take": take,
@@ -41,6 +43,7 @@ func getBuiltGetResponse(articles []Article, skip uint64, take uint64) map[strin
"previous": getArticleSkipTakeFullUrl(skip-take, take),
},
},
"last_page": math.Ceil(float64(articlesCap) / float64(take)),
}
}