From 09cb8a09061d1a8d748ca456780a54a99e1decf3 Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Tue, 12 Aug 2025 12:46:31 +0700 Subject: fix: rm small gap (upper-right corner) fix: correct overflow in blog catalogue fix: better handling of narrow height in blog catalogue feat: include tag count in blog catalogue feat: select all checkboxes on load when none are selected --- main.go | 19 +++++++++++------ views/layouts/general-page.html | 2 +- views/pages/blog-catalogue.html | 36 +++++++++++++++++--------------- views/partials/catalogue-blog-cards.html | 14 +++++++------ 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/main.go b/main.go index 7b8bfd3..c85a304 100644 --- a/main.go +++ b/main.go @@ -146,19 +146,26 @@ func main() { pages = []*b2.BlogPage{} } - tagsSet := make(map[string]struct{}) + tagsMap := make(map[string]int) for _, page := range pages { slog.Debug("enlist page for catalogue", slog.Any("page", page), slog.String("endpoint", "/")) for _, tag := range page.Metadata.Tags { - tagsSet[tag] = struct{}{} + tagsMap[tag]++ } } - tagsArray := make([]string, 0, len(tagsSet)) - for tag := range tagsSet { - tagsArray = append(tagsArray, tag) + type Tag struct { + Name string `json:"Name" yaml:"name"` + Count int `json:"Count" yaml:"count"` } - slices.Sort(tagsArray) + + tagsArray := make([]Tag, 0, len(tagsMap)) + for tag, count := range tagsMap { + tagsArray = append(tagsArray, Tag{tag, count}) + } + slices.SortFunc(tagsArray, func(a Tag, b Tag) int { + return strings.Compare(a.Name, b.Name) + }) content, err := tm.Render("blog-catalogue", fiber.Map{ "QuerySort": querySort, diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html index d5146f8..121a5cd 100644 --- a/views/layouts/general-page.html +++ b/views/layouts/general-page.html @@ -48,7 +48,7 @@
-
+

//

diff --git a/views/pages/blog-catalogue.html b/views/pages/blog-catalogue.html index 6fe1c82..4cda19d 100644 --- a/views/pages/blog-catalogue.html +++ b/views/pages/blog-catalogue.html @@ -1,7 +1,7 @@ {{ define "body" }} -
+
+ class="tags-list ar-gt-0.8:min-w-[10vh] ar-gt-0.8:max-w-[20vh] ar-gt-0.8:w-fit ar-lt-0.8:w-[100%] flex shrink-0 flex-col overflow-y-auto ar-gt-0.8:mr-[1.2vmin]">
{{ .L.BlogSearch.TagsHeader }}
@@ -10,7 +10,7 @@
{{- range .Tags }}
- +
{{- end }}
@@ -59,20 +59,6 @@ {{ define "footer" }} - - + + {{ end }} diff --git a/views/partials/catalogue-blog-cards.html b/views/partials/catalogue-blog-cards.html index 36a6184..a9e4010 100644 --- a/views/partials/catalogue-blog-cards.html +++ b/views/partials/catalogue-blog-cards.html @@ -1,13 +1,15 @@ {{- range .BlogPages }}
- +
-
- {{ .Title }} - // - {{ .ActionDate }} -

{{ .PublishedTime }}

+

{{ .ShortDescription }}

{{ .L.TagsLabel }} {{ .Tags }}

-- cgit v1.3.1+13