完善
This commit is contained in:
parent
c0b3396173
commit
23deffffd1
|
@ -23,7 +23,7 @@ func index(c *gin.Context) {
|
|||
if !helper.IsContainInArr(order, []string{"asc", "desc"}) {
|
||||
order = "asc"
|
||||
}
|
||||
title := models.Options["blogname"]
|
||||
title := ""
|
||||
header := ""
|
||||
postType := []interface{}{"post"}
|
||||
where := models.SqlBuilder{{
|
||||
|
@ -94,6 +94,9 @@ func index(c *gin.Context) {
|
|||
page = pa
|
||||
}
|
||||
}
|
||||
if page == 1 {
|
||||
title = helper.StrJoin(models.Options["blogname"], "-", models.Options["blogdescription"])
|
||||
}
|
||||
|
||||
postIds, totalRaw, err := models.SimplePagination[models.WpPosts](where, "ID", "", page, pageSize, models.SqlBuilder{{"post_date", order}}, join, postType, status)
|
||||
defer func() {
|
||||
|
@ -104,6 +107,9 @@ func index(c *gin.Context) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(postIds) < 1 && category != "" {
|
||||
title = "未找到页面"
|
||||
}
|
||||
var all []uint64
|
||||
var allPosts []models.WpPosts
|
||||
var needQuery []interface{}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
{{template "layout/base" .}}
|
||||
{{define "content" }}
|
||||
{{if .posts}}
|
||||
<div id="primary" class="content-area">
|
||||
<main id="main" class="site-main">
|
||||
{{if .header}}
|
||||
<header class="page-header">
|
||||
<h1 class="page-title">{{.header|unescaped}}</h1>
|
||||
<h1 class="page-title">
|
||||
{{if .search}}
|
||||
{{.header}}
|
||||
{{else}}
|
||||
{{.header |unescaped}}
|
||||
{{end}}
|
||||
</h1>
|
||||
</header>
|
||||
{{end}}
|
||||
{{ range $k,$v:=.posts}}
|
||||
|
@ -56,4 +63,8 @@
|
|||
{{template "layout/page" .}}
|
||||
</main><!-- .site-main -->
|
||||
</div>
|
||||
{{else }}
|
||||
{{template "layout/empty" .}}
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
|
37
templates/layout/empty.html
Normal file
37
templates/layout/empty.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
{{define "layout/empty"}}
|
||||
<section id="primary" class="content-area">
|
||||
<main id="main" class="site-main">
|
||||
|
||||
<section class="no-results not-found">
|
||||
<header class="page-header">
|
||||
<h1 class="page-title">
|
||||
{{if .search}}
|
||||
未找到
|
||||
{{else}}
|
||||
有点尴尬诶!该页无法显示。
|
||||
{{end}}
|
||||
</h1>
|
||||
</header><!-- .page-header -->
|
||||
|
||||
<div class="page-content">
|
||||
|
||||
<p>{{if .search}}
|
||||
抱歉,没有符合您搜索条件的结果。请换其它关键词再试。
|
||||
{{else}}
|
||||
这儿似乎什么都没有,试试搜索?
|
||||
{{end}}
|
||||
</p>
|
||||
<form role="search" method="get" class="search-form" action="https://www.xloyy.com/">
|
||||
<label>
|
||||
<span class="screen-reader-text">搜索:</span>
|
||||
<input type="search" class="search-field" placeholder="搜索…" value="{{.search}}" name="s">
|
||||
</label>
|
||||
<input type="submit" class="search-submit screen-reader-text" value="搜索">
|
||||
</form>
|
||||
|
||||
</div><!-- .page-content -->
|
||||
</section><!-- .no-results -->
|
||||
|
||||
</main><!-- .site-main -->
|
||||
</section>
|
||||
{{end}}
|
Loading…
Reference in New Issue
Block a user