commit 8f84297d89fb98d9afe2c642839daaa7be675aba
parent a3eabbe256de2019a14ae8a774e2937282dea348
Author: breadcat <breadcat@users.noreply.github.com>
Date: Tue, 30 Jun 2026 13:27:51 +0100
Add item count to breadcrumb bar
We're also slowly getting rid of the types include
Diffstat:
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/include-filters.go b/include-filters.go
@@ -8,6 +8,12 @@ import (
"strings"
)
+type Breadcrumb struct {
+ Name string
+ URL string
+ Count int // 0 = not shown
+}
+
func untaggedFilesHandler(w http.ResponseWriter, r *http.Request) {
page := pageFromRequest(r)
perPage := perPageFromConfig(50)
@@ -186,6 +192,9 @@ func tagFilterHandler(w http.ResponseWriter, r *http.Request) {
Untagged: nil,
Breadcrumbs: []Breadcrumb{},
}, 1, len(files), len(files), r)
+ if len(breadcrumbs) > 0 {
+ breadcrumbs[len(breadcrumbs)-1].Count = len(files)
+ }
pageData.Breadcrumbs = breadcrumbs
renderTemplate(w, "list.html", pageData)
@@ -223,6 +232,9 @@ func tagFilterHandler(w http.ResponseWriter, r *http.Request) {
Untagged: nil,
Breadcrumbs: []Breadcrumb{},
}, page, total, perPage, r)
+ if len(breadcrumbs) > 0 {
+ breadcrumbs[len(breadcrumbs)-1].Count = total
+ }
pageData.Breadcrumbs = breadcrumbs
renderTemplate(w, "list.html", pageData)
diff --git a/include-types.go b/include-types.go
@@ -21,11 +21,6 @@ type Config struct {
SedRules []SedRule
}
-type Breadcrumb struct {
- Name string
- URL string
-}
-
type TagAliasGroup struct {
Category string `json:"category"`
Aliases []string `json:"aliases"`
diff --git a/templates/list.html b/templates/list.html
@@ -9,6 +9,7 @@
{{else}}
<a href="/tags#tag-{{$crumb.Name}}">{{$crumb.Name}}</a>
{{end}}
+ {{if gt $crumb.Count 0}} ({{$crumb.Count}}){{end}}
{{end}}
</div>
{{else}}