WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c29b218

Browse files
committed
内容阅读SEO标题优化
1 parent dd568ed commit c29b218

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

controllers/DocumentController.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,7 @@ func (this *DocumentController) Read() {
267267
}
268268

269269
if len(parentTitle) > 0 {
270-
parentTitleStr := strings.Join(parentTitle, " - ")
271-
parentTitleSub := beego.Substr(parentTitleStr, 0, 50)
272-
if len(parentTitleStr) > 50 {
273-
parentTitleSub = parentTitleSub + "..."
274-
}
275-
seo["title"] = doc.DocumentName + " - " + parentTitleSub + " - 《" + bookResult.BookName + "》"
270+
seo["title"] = parentTitle + " - " + doc.DocumentName + " - 《" + bookResult.BookName + "》"
276271
}
277272

278273
//SEO

models/document.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,10 @@ func (m *Document) GetMenuTop(bookId int) (docs []*Document, err error) {
474474
return
475475
}
476476

477-
func (m *Document) GetParentTitle(pid int) (title []string) {
477+
func (m *Document) GetParentTitle(pid int) (title string) {
478478
var d Document
479479
orm.NewOrm().QueryTable(m).Filter("document_id", pid).One(&d, "document_id", "parent_id", "document_name")
480-
if d.DocumentId > 0 {
481-
title = append(title, d.DocumentName)
482-
}
483-
484-
if d.ParentId > 0 {
485-
title = append(title, m.GetParentTitle(d.ParentId)...)
486-
}
487-
488-
return
480+
return d.DocumentName
489481
}
490482

491483
//自动生成下一级的内容

0 commit comments

Comments
 (0)