摘要为空取前120字符,删除tag同步删除关联
This commit is contained in:
@@ -131,10 +131,10 @@ func IndexView(c *gin.Context) {
|
||||
|
||||
// 如果摘要为空,则从内容中提取摘要
|
||||
for i := range posts {
|
||||
if posts[i].Summary == "" && posts[i].Content != "" && len(posts[i].Content) > 120 {
|
||||
posts[i].Summary = posts[i].Content[:120]
|
||||
} else {
|
||||
posts[i].Summary = posts[i].Content
|
||||
p := &posts[i]
|
||||
if p.Summary == "" && p.SearchableText != "" {
|
||||
runes := []rune(p.SearchableText)
|
||||
p.Summary = string(runes[:min(len(runes), 120)])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user