完善
This commit is contained in:
parent
ad875857d8
commit
179e1e14e2
@ -23,10 +23,12 @@ var recentPostsArgs = map[string]string{
|
|||||||
"{$after_sidebar}": "",
|
"{$after_sidebar}": "",
|
||||||
"{$nav}": "",
|
"{$nav}": "",
|
||||||
"{$navCloser}": "",
|
"{$navCloser}": "",
|
||||||
|
"{$title}": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
var recentPostsTemplate = `{$before_widget}
|
var recentPostsTemplate = `{$before_widget}
|
||||||
{$nav}
|
{$nav}
|
||||||
|
{$title}
|
||||||
<ul>
|
<ul>
|
||||||
{$li}
|
{$li}
|
||||||
</ul>
|
</ul>
|
||||||
@ -44,13 +46,14 @@ func RecentPosts(h *Handle) string {
|
|||||||
args := GetComponentsArgs(h, components.RecentPostsArgs, recentPostsArgs)
|
args := GetComponentsArgs(h, components.RecentPostsArgs, recentPostsArgs)
|
||||||
args = maps.Merge(recentPostsArgs, args)
|
args = maps.Merge(recentPostsArgs, args)
|
||||||
conf := wpconfig.GetPHPArrayVal[map[any]any]("widget_recent-posts", recentConf, int64(2))
|
conf := wpconfig.GetPHPArrayVal[map[any]any]("widget_recent-posts", recentConf, int64(2))
|
||||||
|
args["{$title}"] = str.Join(args["{$before_title}"], conf["title"].(string), args["{$after_title}"])
|
||||||
if slice.IsContained(h.CommonThemeMods().ThemeSupport.HTML5, "navigation-widgets") {
|
if slice.IsContained(h.CommonThemeMods().ThemeSupport.HTML5, "navigation-widgets") {
|
||||||
args["{$nav}"] = fmt.Sprintf(`<nav aria-label="%s">`, conf["title"])
|
args["{$nav}"] = fmt.Sprintf(`<nav aria-label="%s">`, conf["title"])
|
||||||
args["{$navCloser}"] = "</nav>"
|
args["{$navCloser}"] = "</nav>"
|
||||||
}
|
}
|
||||||
currentPostId := uint64(0)
|
currentPostId := uint64(0)
|
||||||
if h.Scene() == constraints.Detail {
|
if h.Scene() == constraints.Detail {
|
||||||
currentPostId = h.Detail.Post.Id
|
currentPostId = str.ToInteger(h.C.Param("id"), uint64(0))
|
||||||
}
|
}
|
||||||
posts := slice.Map(cache.RecentPosts(h.C, int(conf["number"].(int64))), func(t models.Posts) string {
|
posts := slice.Map(cache.RecentPosts(h.C, int(conf["number"].(int64))), func(t models.Posts) string {
|
||||||
t = ProjectTitle(t)
|
t = ProjectTitle(t)
|
||||||
|
Loading…
Reference in New Issue
Block a user