diff --git a/internal/theme/wp/recentposts.go b/internal/theme/wp/recentposts.go
index d645c16..4274938 100644
--- a/internal/theme/wp/recentposts.go
+++ b/internal/theme/wp/recentposts.go
@@ -23,10 +23,12 @@ var recentPostsArgs = map[string]string{
"{$after_sidebar}": "",
"{$nav}": "",
"{$navCloser}": "",
+ "{$title}": "",
}
var recentPostsTemplate = `{$before_widget}
{$nav}
+{$title}
@@ -44,13 +46,14 @@ func RecentPosts(h *Handle) string {
args := GetComponentsArgs(h, components.RecentPostsArgs, recentPostsArgs)
args = maps.Merge(recentPostsArgs, args)
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") {
args["{$nav}"] = fmt.Sprintf(`"
}
currentPostId := uint64(0)
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 {
t = ProjectTitle(t)
@@ -62,10 +65,10 @@ func RecentPosts(h *Handle) string {
if currentPostId == t.Id {
ariaCurrent = ` aria-current="page"`
}
- return fmt.Sprintf(`
- %s
- %s
-`, str.Join("/p/", number.ToString(t.Id)), ariaCurrent, t.PostTitle, date)
+ return fmt.Sprintf(`
+ %s
+ %s
+ `, str.Join("/p/", number.ToString(t.Id)), ariaCurrent, t.PostTitle, date)
})
s := strings.ReplaceAll(recentPostsTemplate, "{$li}", strings.Join(posts, "\n"))
return str.Replace(s, args)