Skip to content

Commit

Permalink
👓搜索功能优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Deali-Axy committed Jun 28, 2023
1 parent 361d17e commit ae3c621
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions StarBlog.Web/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public SearchController(IBaseRepository<Post> postRepo, IBaseRepository<Category

public IActionResult Blog(string keyword, int categoryId = 0, int page = 1, int pageSize = 5) {
var posts = _postRepo
.Where(a => a.IsPublish)
.Where(a => a.Title!.Contains(keyword))
.Include(a => a.Category)
.ToList();
Expand Down
2 changes: 1 addition & 1 deletion StarBlog.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<div class="px-3 py-2 border-bottom mb-3">
<div class="container d-flex flex-wrap justify-content-center">
<form class="col-12 col-lg-auto mb-2 mb-lg-0 me-lg-auto"
asp-controller="Search" asp-action="Blog">
asp-controller="Search" asp-action="Blog" method="get">
<input type="search" class="form-control" placeholder="Search..." aria-label="Search" name="keyword">
</form>

Expand Down

0 comments on commit ae3c621

Please sign in to comment.