Skip to content

Commit

Permalink
🔨修复文章的slug相关bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Deali-Axy committed Jul 17, 2023
1 parent a924cea commit bccfe73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions StarBlog.Web/Services/PostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public async Task<IPagedList<Post>> GetPagedList(PostQueryParameters param) {
}

// 状态过滤
if (!string.IsNullOrEmpty(param.Status)) {
if (!string.IsNullOrWhiteSpace(param.Status)) {
querySet = querySet.Where(a => a.Status == param.Status);
}

Expand All @@ -123,12 +123,12 @@ public async Task<IPagedList<Post>> GetPagedList(PostQueryParameters param) {
}

// 关键词过滤
if (!string.IsNullOrEmpty(param.Search)) {
if (!string.IsNullOrWhiteSpace(param.Search)) {
querySet = querySet.Where(a => a.Title.Contains(param.Search));
}

// 排序
if (!string.IsNullOrEmpty(param.SortBy)) {
if (!string.IsNullOrWhiteSpace(param.SortBy)) {
// 是否升序
var isAscending = !param.SortBy.StartsWith("-");
var orderByProperty = param.SortBy.Trim('-');
Expand Down
2 changes: 1 addition & 1 deletion StarBlog.Web/Views/Shared/Widgets/PostCard.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<p class="card-text">
@Model.Summary
</p>
@if (Model.Slug != null) {
@if (!string.IsNullOrWhiteSpace(Model.Slug)) {
<a class="btn btn-outline-secondary stretched-link" href="/p/@Model.Slug">
查看全文
</a>
Expand Down

0 comments on commit bccfe73

Please sign in to comment.