update AcceptedAnswer author

This commit is contained in:
aichy126 2022-12-09 11:18:04 +08:00
parent e2146ad50b
commit 15e174551a
2 changed files with 7 additions and 0 deletions

View File

@ -185,6 +185,9 @@ func (tc *TemplateController) QuestionInfo(ctx *gin.Context) {
jsonLD.MainEntity.AcceptedAnswer.Text = htmltext.ClearText(answer.HTML)
jsonLD.MainEntity.AcceptedAnswer.UpvoteCount = answer.VoteCount
jsonLD.MainEntity.AcceptedAnswer.URL = fmt.Sprintf("%s/%s", siteInfo.Canonical, answer.ID)
jsonLD.MainEntity.AcceptedAnswer.Author.Type = "Person"
jsonLD.MainEntity.AcceptedAnswer.Author.Name = answer.UserInfo.DisplayName
} else {
item := &schema.SuggestedAnswerItem{}
item.Type = "Answer"

View File

@ -34,6 +34,10 @@ type AcceptedAnswerItem struct {
Text string `json:"text"`
UpvoteCount int `json:"upvoteCount"`
URL string `json:"url"`
Author struct {
Type string `json:"@type"`
Name string `json:"name"`
} `json:"author"`
}
type SuggestedAnswerItem struct {