摘要为空取前120字符,删除tag同步删除关联

This commit is contained in:
2026-09-08 17:48:40 +08:00
parent caa9436e6a
commit f376d94a49
2 changed files with 12 additions and 5 deletions
+4 -4
View File
@@ -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)])
}
}