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.
add permalink
aichy126999ee83c8d42
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.goindex e9b51e57..4abec41b 100644--- a/internal/controller/template_controller.go+++ b/internal/controller/template_controller.go@@ -162,6 +162,9 @@ func (tc *TemplateController) QuestionInfo(ctx *gin.Context) {siteInfo := tc.SiteInfo(ctx)encodeTitle := htmltext.UrlTitle(detail.Title)siteInfo.Canonical = fmt.Sprintf("%s/questions/%s/%s", siteInfo.General.SiteUrl, id, encodeTitle)+ if siteInfo.General.PermaLink == schema.PermaLinkQuestionID {+ siteInfo.Canonical = fmt.Sprintf("%s/questions/%s", siteInfo.General.SiteUrl, id)+ }jsonLD := &schema.QAPageJsonLD{}jsonLD.Context = "https://schema.org"jsonLD.Type = "QAPage"diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.goindex 92c6153f..b92213f5 100644--- a/internal/schema/siteinfo_schema.go+++ b/internal/schema/siteinfo_schema.go@@ -5,6 +5,9 @@ import ("net/url")+const PermaLinkQuestionIDAndTitle = 1+const PermaLinkQuestionID = 2+// SiteGeneralReq site general requesttype SiteGeneralReq struct {Name string `validate:"required,gt=1,lte=128" form:"name" json:"name"`@@ -12,6 +15,7 @@ type SiteGeneralReq struct {Description string `validate:"required,gt=3,lte=2000" form:"description" json:"description"`SiteUrl string `validate:"required,gt=1,lte=512,url" form:"site_url" json:"site_url"`ContactEmail string `validate:"required,gt=1,lte=512,email" form:"contact_email" json:"contact_email"`+ PermaLink int `validate:"required,lte=3,gte=0" form:"permalink" json:"permalink"`}func (r *SiteGeneralReq) FormatSiteUrl() {