mirror of https://gitee.com/answerdev/answer.git
fix(robots): Add SEO config initialize data at installation
This commit is contained in:
parent
6e1f4841f1
commit
05e8ce3a46
|
@ -11,6 +11,23 @@ import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultSEORobotTxt = `User-agent: *
|
||||||
|
Disallow: /admin
|
||||||
|
Disallow: /search
|
||||||
|
Disallow: /install
|
||||||
|
Disallow: /review
|
||||||
|
Disallow: /users/login
|
||||||
|
Disallow: /users/register
|
||||||
|
Disallow: /users/account-recovery
|
||||||
|
Disallow: /users/oauth/*
|
||||||
|
Disallow: /users/*/*
|
||||||
|
Disallow: /answer/api
|
||||||
|
Disallow: /*?code*
|
||||||
|
|
||||||
|
Sitemap: `
|
||||||
|
)
|
||||||
|
|
||||||
var tables = []interface{}{
|
var tables = []interface{}{
|
||||||
&entity.Activity{},
|
&entity.Activity{},
|
||||||
&entity.Answer{},
|
&entity.Answer{},
|
||||||
|
@ -130,6 +147,19 @@ func initSiteInfo(engine *xorm.Engine, language, siteName, siteURL, contactEmail
|
||||||
Content: string(loginConfigDataBytes),
|
Content: string(loginConfigDataBytes),
|
||||||
Status: 1,
|
Status: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
seoData := map[string]string{
|
||||||
|
"robots": defaultSEORobotTxt + siteURL + "/sitemap.xml",
|
||||||
|
}
|
||||||
|
seoDataBytes, _ := json.Marshal(seoData)
|
||||||
|
_, err = engine.InsertOne(&entity.SiteInfo{
|
||||||
|
Type: "seo",
|
||||||
|
Content: string(seoDataBytes),
|
||||||
|
Status: 1,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue