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 page meta
aichy126e59e95fe115d
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.goindex d78f6a73..58ff3730 100644--- a/internal/controller/template_controller.go+++ b/internal/controller/template_controller.go@@ -6,6 +6,7 @@ import ("html/template""net/http""regexp"+ "strings""time""github.com/answerdev/answer/internal/base/handler"@@ -190,6 +191,13 @@ func (tc *TemplateController) QuestionInfo(ctx *gin.Context) {siteInfo.JsonLD = `<script data-react-helmet="true" type="application/ld+json">` + string(jsonLDStr) + ` </script>`}+ siteInfo.Description = htmltext.FetchExcerpt(detail.HTML, "...", 240)+ tags := make([]string, 0)+ for _, tag := range detail.Tags {+ tags = append(tags, tag.DisplayName)+ }+ siteInfo.Keywords = strings.Replace(strings.Trim(fmt.Sprint(tags), "[]"), " ", ",", -1)+tc.html(ctx, http.StatusOK, "question-detail.html", siteInfo, gin.H{"id": id,"answerid": answerid,@@ -254,6 +262,10 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) {siteInfo := tc.SiteInfo(ctx)siteInfo.Canonical = fmt.Sprintf("%s/tags/%s", siteInfo.General.SiteUrl, tag)++ siteInfo.Description = htmltext.FetchExcerpt(taginifo.ParsedText, "...", 240)+ siteInfo.Keywords = taginifo.DisplayName+tc.html(ctx, http.StatusOK, "tag-detail.html", siteInfo, gin.H{"tag": taginifo,"questionList": questionList,@@ -307,6 +319,11 @@ func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteIdata["siteinfo"] = siteInfodata["scriptPath"] = tc.scriptPathdata["cssPath"] = tc.cssPath+ data["keywords"] = siteInfo.Keywords+ if siteInfo.Description == "" {+ siteInfo.Description = siteInfo.General.Description+ }+ data["description"] = siteInfo.Descriptiondata["language"] = handler.GetLang(ctx)data["timezone"] = siteInfo.Interface.TimeZonediff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.goindex 9e77a0f4..920d8807 100644--- a/internal/schema/siteinfo_schema.go+++ b/internal/schema/siteinfo_schema.go@@ -106,12 +106,14 @@ type SiteInfoResp struct {Branding *SiteBrandingResp `json:"branding"`}type TemplateSiteInfoResp struct {- General *SiteGeneralResp `json:"general"`- Interface *SiteInterfaceResp `json:"interface"`- Branding *SiteBrandingResp `json:"branding"`- Year string- Canonical string- JsonLD string+ General *SiteGeneralResp `json:"general"`+ Interface *SiteInterfaceResp `json:"interface"`+ Branding *SiteBrandingResp `json:"branding"`+ Year string+ Canonical string+ JsonLD string+ Keywords string+ Description string}// UpdateSMTPConfigReq get smtp config requestdiff --git a/ui/template/header.html b/ui/template/header.htmlindex baf712e5..b265fcf7 100644--- a/ui/template/header.html+++ b/ui/template/header.html@@ -5,7 +5,8 @@<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width,initial-scale=1" />-+ <meta name="description" content="{{.description}}" />+ {{if .keywords }}<meta name="keywords" content="{{.keywords}}" />{{end}}<link rel="canonical" href="{{.siteinfo.Canonical}}" /><link rel="manifest" href="/manifest.json"/><link href="{{.cssPath}}" rel="stylesheet" />