小优化

This commit is contained in:
xing 2023-05-10 14:28:21 +08:00
parent dfe7bb3181
commit 40451970a0

View File

@ -70,15 +70,11 @@ func PostPlugin(calls ...PostsPlugin) PostsPlugin {
}
func UsePostsPlugins() PostsPlugin {
p := config.GetConfig().ListPagePlugins
var pluginss []func(PostsPlugin, *Handle, *models.Posts)
m := pluginFns.Load()
for _, s := range p {
f, ok := m[s]
if ok {
pluginss = append(pluginss, f)
}
}
pluginss := slice.FilterAndMap(config.GetConfig().ListPagePlugins, func(t string) (func(PostsPlugin, *Handle, *models.Posts), bool) {
f, ok := m[t]
return f, ok
})
slice.Unshift(&pluginss, PasswordProject)
return PostsPlugins(PostPlugin(ordinaryPlugin.Load()...), pluginss...)
}