mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
Fix some bugs in full-text search
This commit is contained in:
@@ -372,9 +372,15 @@ func (ma *MApp) SearchHandler(ctx *gin.Context) {
|
||||
nxtPage = allPage
|
||||
}
|
||||
|
||||
// generate search posts
|
||||
start := (curPage - 1) * size
|
||||
offset := curPage * size
|
||||
|
||||
var resultPosts []model.MPost
|
||||
for _, searchPost := range searchPosts {
|
||||
resultPosts = append(resultPosts, *ma.IndexedPosts[searchPost.DocId])
|
||||
if len(searchPosts) > 0 {
|
||||
for i := start; i < utils.Min(len(searchPosts), offset); i++ {
|
||||
resultPosts = append(resultPosts, *ma.IndexedPosts[searchPosts[i].DocId])
|
||||
}
|
||||
}
|
||||
|
||||
resData := gin.H{
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
<div class="col-12 col-md-8">
|
||||
<div class="search-post-pagination">
|
||||
<span class="search-post-pagination-item">
|
||||
<a href="/search?page={{ .page_info.pre_page }}">
|
||||
<a href="/search?keyword={{ .search_post.keyword }}&page={{ .page_info.pre_page }}">
|
||||
<
|
||||
</a>
|
||||
</span>
|
||||
@@ -94,7 +94,7 @@
|
||||
{{ .page_info.cur_page }} / {{ .page_info.all_page }}
|
||||
</span>
|
||||
<span class="search-post-pagination-item">
|
||||
<a href="/search?page={{ .page_info.nxt_page }}">
|
||||
<a href="/search?keyword={{ .search_post.keyword }}&page={{ .page_info.nxt_page }}">
|
||||
>
|
||||
</a>
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user