文章默认排序设置
This commit is contained in:
parent
c842c3a293
commit
ca349f55d7
|
@ -71,3 +71,7 @@ trustIps: []
|
|||
trustServerNames: ["xy.test","blog.xy.test"]
|
||||
# port
|
||||
port: 8082
|
||||
# 主题 为空值为option template,没有就默认为twentyfifteen
|
||||
theme: "twentyfifteen"
|
||||
# 文档排序默认升序还是降序
|
||||
postOrder: "desc"
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/fthvgb1/wp-go/helper/slice"
|
||||
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||
"github.com/fthvgb1/wp-go/internal/pkg/cache"
|
||||
"github.com/fthvgb1/wp-go/internal/pkg/config"
|
||||
"github.com/fthvgb1/wp-go/internal/pkg/dao"
|
||||
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
||||
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
||||
|
@ -92,10 +93,17 @@ func (h *indexHandle) getSearchKey() string {
|
|||
return fmt.Sprintf("action:%s|%s|%s|%s|%s|%s|%d|%d", h.author, h.search, h.orderBy, h.order, h.category, h.categoryType, h.page, h.pageSize)
|
||||
}
|
||||
|
||||
var orders = []string{"asc", "desc"}
|
||||
|
||||
func (h *indexHandle) parseParams() (err error) {
|
||||
h.order = h.c.Query("order")
|
||||
if !slice.IsContained(h.order, []string{"asc", "desc"}) {
|
||||
|
||||
if !slice.IsContained(h.order, orders) {
|
||||
order := config.Conf.Load().PostOrder
|
||||
h.order = "asc"
|
||||
if order != "" && slice.IsContained(order, orders) {
|
||||
h.order = order
|
||||
}
|
||||
}
|
||||
year := h.c.Param("year")
|
||||
if year != "" {
|
||||
|
|
|
@ -38,6 +38,7 @@ type Config struct {
|
|||
TrustIps []string `yaml:"trustIps"`
|
||||
TrustServerNames []string `yaml:"trustServerNames"`
|
||||
Theme string `yaml:"theme"`
|
||||
PostOrder string `yaml:"postOrder"`
|
||||
}
|
||||
|
||||
type Mail struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user