From 3ba2c02db56e473d6100035910dd6dc84d4b36f6 Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 1 May 2023 13:34:23 +0800 Subject: [PATCH] fix bug --- helper/maps/map.go | 2 +- internal/theme/wp/components/widget/archive.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helper/maps/map.go b/helper/maps/map.go index a73099b..869e429 100644 --- a/helper/maps/map.go +++ b/helper/maps/map.go @@ -153,7 +153,7 @@ func MergeBy[K comparable, V any](fn func(k K, v1, v2 V) (V, bool), m ...map[K]V func FilterZeroMerge[K comparable, V any](m ...map[K]V) map[K]V { if len(m) < 1 { - panic("no map") + return nil } else if len(m) < 2 { return m[0] } diff --git a/internal/theme/wp/components/widget/archive.go b/internal/theme/wp/components/widget/archive.go index 2018b9d..55554d8 100644 --- a/internal/theme/wp/components/widget/archive.go +++ b/internal/theme/wp/components/widget/archive.go @@ -47,7 +47,7 @@ func Archive(h *wp.Handle, id string) string { conf := reload.GetAnyValBys("widget-archive-conf", h, func(h *wp.Handle) map[any]any { archivesConfig := archivesConfig() conf := wpconfig.GetPHPArrayVal("widget_archives", archivesConfig, int64(2)) - return conf + return maps.FilterZeroMerge(archivesConfig, conf) }) args := reload.GetAnyValBys("widget-archive-args", h, func(h *wp.Handle) map[string]string {