Skip to content

Commit

Permalink
fix: pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
1379 authored and 1379 committed Dec 3, 2022
1 parent d07cf6d commit ec9c203
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion resources/template/theme/default-theme-anatole
2 changes: 1 addition & 1 deletion service/impl/post_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (p *postTagServiceImpl) PagePost(ctx context.Context, postQuery param.PostQ
postDo = postDo.Where(postDAL.Status.In(statuesValue...))
}
if postQuery.TagID != nil {
postDo.Join(&entity.PostTag{}, postDAL.ID.EqCol(postTagDAL.PostID)).Where(postTagDAL.ID.Eq(*postQuery.TagID))
postDo.Join(&entity.PostTag{}, postDAL.ID.EqCol(postTagDAL.PostID)).Where(postTagDAL.TagID.Eq(*postQuery.TagID))
}
posts, totalCount, err := postDo.FindByPage(postQuery.PageNum*postQuery.PageSize, postQuery.PageSize)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions template/extension/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *paginationExtension) addArchivesPagination() {
if err != nil {
return nil, err
}
return p.getPagination(ctx, page, total, display, prefix, suffix)
return p.getPagination(ctx, page, total, display, "/"+prefix, suffix)
}
p.Template.AddFunc("archivesPagination", archivesPagination)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func (p *paginationExtension) addTagPostsPagination() {
if err != nil {
return nil, err
}
return p.getPagination(ctx, page, total, display, tagPrefix.(string)+"/"+slug, suffix)
return p.getPagination(ctx, page, total, display, "/"+tagPrefix.(string)+"/"+slug, suffix)
}
p.Template.AddFunc("tagPostsPagination", tagPostsPagination)
}
Expand All @@ -97,7 +97,7 @@ func (p *paginationExtension) addCategoryPostsPagination() {
if err != nil {
return nil, err
}
return p.getPagination(ctx, page, total, display, categoryPrefix.(string)+"/"+slug, suffix)
return p.getPagination(ctx, page, total, display, "/"+categoryPrefix.(string)+"/"+slug, suffix)
}
p.Template.AddFunc("categoryPostsPagination", categoryPostsPagination)
}
Expand All @@ -113,7 +113,7 @@ func (p *paginationExtension) addPhotosPagination() {
if err != nil {
return nil, err
}
return p.getPagination(ctx, page, total, display, prefix, suffix)
return p.getPagination(ctx, page, total, display, "/"+prefix, suffix)
}
p.Template.AddFunc("photosPagination", photosPagination)
}
Expand All @@ -129,7 +129,7 @@ func (p *paginationExtension) addJournalsPagination() {
if err != nil {
return nil, err
}
return p.getPagination(ctx, page, total, display, prefix, suffix)
return p.getPagination(ctx, page, total, display, "/"+prefix, suffix)
}
p.Template.AddFunc("journalsPagination", journalsPagination)
}
Expand All @@ -154,12 +154,12 @@ func (p *paginationExtension) getPagination(ctx context.Context, page, total, di

rainbow := util.RainbowPage(page+1, total, display)

rainbowPages := make([]vo.RainbowPage, len(rainbow), len(rainbow))
rainbowPages := make([]vo.RainbowPage, len(rainbow))

nextPageFullPath += prefix + "/page/" + strconv.Itoa(page+2) + suffix

if page == 1 {
prevPageFullPath += "/"
prevPageFullPath += prefix + "/"
} else {
prevPageFullPath += prefix + "/page/" + strconv.Itoa(page) + suffix
}
Expand Down

0 comments on commit ec9c203

Please sign in to comment.