This commit is contained in:
xing 2022-09-17 09:52:11 +08:00
parent 46088d1ed6
commit 22b0824d5f
2 changed files with 9 additions and 2 deletions

View File

@ -23,6 +23,7 @@ func index(c *gin.Context) {
if !helper.IsContainInArr(order, []string{"asc", "desc"}) { if !helper.IsContainInArr(order, []string{"asc", "desc"}) {
order = "asc" order = "asc"
} }
title := models.Options["blogname"]
header := "" header := ""
where := models.SqlBuilder{{ where := models.SqlBuilder{{
"post_type", "post", "post_type", "post",
@ -39,7 +40,9 @@ func index(c *gin.Context) {
where = append(where, []string{ where = append(where, []string{
"month(post_date)", month, "month(post_date)", month,
}) })
header = fmt.Sprintf("月度归档: <span>%s年%s月</span>", year, month) ss := fmt.Sprintf("%s年%s月", year, month)
header = fmt.Sprintf("月度归档: <span>%s</span>", ss)
title = ss
} }
tt := "" tt := ""
category := c.Param("category") category := c.Param("category")
@ -48,10 +51,12 @@ func index(c *gin.Context) {
if category != "" { if category != "" {
tt = "post_tag" tt = "post_tag"
header = fmt.Sprintf("标签: <span>%s</span>", category) header = fmt.Sprintf("标签: <span>%s</span>", category)
title = category
} }
} else { } else {
tt = "category" tt = "category"
header = fmt.Sprintf("分类: <span>%s</span>", category) header = fmt.Sprintf("分类: <span>%s</span>", category)
title = category
} }
s := c.Query("s") s := c.Query("s")
if s != "" && strings.Replace(s, " ", "", -1) != "" { if s != "" && strings.Replace(s, " ", "", -1) != "" {
@ -61,6 +66,7 @@ func index(c *gin.Context) {
"or", "post_content", "like", q, "", "or", "post_content", "like", q, "",
}) })
header = fmt.Sprintf("%s的搜索结果", s) header = fmt.Sprintf("%s的搜索结果", s)
title = header
} else { } else {
status = append(status, "private") status = append(status, "private")
} }
@ -173,6 +179,7 @@ func index(c *gin.Context) {
"pagination": pagination(page, totalPage, 1, c.Request.URL.Path, q), "pagination": pagination(page, totalPage, 1, c.Request.URL.Path, q),
"search": s, "search": s,
"header": header, "header": header,
"title": title,
}) })
} }

View File

@ -2,7 +2,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="max-image-preview:large"> <meta name="robots" content="max-image-preview:large">
<title>{{ .options.blogname }}</title> <title>{{ .title }}</title>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="/wp-content/themes/twentyfifteen/js/html5.js?ver=3.7.0"></script> <script src="/wp-content/themes/twentyfifteen/js/html5.js?ver=3.7.0"></script>
<![endif]--> <![endif]-->