Pagination links fix.

This commit is contained in:
Stanislav Nikitin 2018-05-01 17:52:40 +05:00
parent 850fbb55ab
commit 73505ffdb6

View File

@ -77,8 +77,17 @@ func CreateHTML(currentPage int, pages int, linksBase string) string {
} }
pagination := strings.Replace(string(paginationHTMLRaw), "{paginationLinks}", paginationString, 1) pagination := strings.Replace(string(paginationHTMLRaw), "{paginationLinks}", paginationString, 1)
pagination = strings.Replace(pagination, "{nextPageLink}", linksBase+strconv.Itoa(currentPage+1), 1) if currentPage+1 <= pages {
pagination = strings.Replace(pagination, "{previousPageLink}", linksBase+strconv.Itoa(currentPage-1), 1) pagination = strings.Replace(pagination, "{nextPageLink}", linksBase+strconv.Itoa(currentPage+1), 1)
} else {
pagination = strings.Replace(pagination, "{nextPageLink}", linksBase+strconv.Itoa(pages), 1)
}
if currentPage-1 > 1 {
pagination = strings.Replace(pagination, "{previousPageLink}", linksBase+strconv.Itoa(currentPage-1), 1)
} else {
pagination = strings.Replace(pagination, "{previousPageLink}", linksBase, 1)
}
return pagination return pagination
} }