package tpl import ( "fmt" "sh.org.ru/pkg/model" "strconv" ) templ Index(quotes []model.Quote, page, count int) { @Layout(HeaderParams{ Title: "Цитатник Рунета", Description: "Новый цитатник Рунета", URL: "https://sh.org.ru/", }) { for _, q := range quotes { @Quote(&q) } Всего { strconv.Itoa(count) } цитат. } } func generatePagination(currentPage, totalPages int) []string { pagination := make([]string, 0, 11) if currentPage <= 3 { for i := 0; i <= currentPage+3; i++ { pagination = append(pagination, strconv.Itoa(i)) } pagination = append(pagination, "...") pagination = append(pagination, strconv.Itoa(totalPages-2)) pagination = append(pagination, strconv.Itoa(totalPages-1)) pagination = append(pagination, strconv.Itoa(totalPages)) } else if currentPage >= totalPages-3 { pagination = append(pagination, "0") pagination = append(pagination, "1") pagination = append(pagination, "2") pagination = append(pagination, "...") for i := currentPage - 3; i <= totalPages; i++ { pagination = append(pagination, strconv.Itoa(i)) } } else { pagination = append(pagination, "0") pagination = append(pagination, "...") for i := currentPage - 2; i <= currentPage+2; i++ { pagination = append(pagination, strconv.Itoa(i)) } pagination = append(pagination, "...") pagination = append(pagination, strconv.Itoa(totalPages)) } return pagination }