Skip to content

Commit

Permalink
fix(search): add category to links in pagination
Browse files Browse the repository at this point in the history
Thank you, @a0eoc, for reporting this issue.
  • Loading branch information
vednoc committed Sep 25, 2023
1 parent 82958d5 commit 0fb12bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions handlers/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Search(c *fiber.Ctx) error {

p := models.NewPagination(page, total, sort, c.Path())
p.Query = keyword
p.Category = category
if p.OutOfBounds() {
return c.Redirect(p.URL(p.Now), 302)
}
Expand Down
12 changes: 9 additions & 3 deletions models/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (

// Pagination is a field-aligned struct optimized for pagination.
type Pagination struct {
Path string
Sort string
Query string
Path string
Sort string
Query string
Category string

Prev3 int
Prev2 int
Prev1 int
Expand Down Expand Up @@ -48,6 +50,10 @@ func (p Pagination) URL(page int) string {
s += fmt.Sprintf("&q=%s", url.QueryEscape(p.Query))
}

if p.Category != "" {
s += fmt.Sprintf("&category=%s", url.QueryEscape(p.Category))
}

return s
}

Expand Down

0 comments on commit 0fb12bb

Please sign in to comment.