Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

update AcceptedAnswer author

aichy12615e174551a09
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.go
index efe391e3..c39803d8 100644
--- a/internal/controller/template_controller.go
+++ b/internal/controller/template_controller.go
@@ -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"
diff --git a/internal/schema/template_schema.go b/internal/schema/template_schema.go
index 0e498702..39f55429 100644
--- a/internal/schema/template_schema.go
+++ b/internal/schema/template_schema.go
@@ -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 {