Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 4dba6c0

Browse files
Populate hub chart with distributions and top entities
Hub pages now include: - distributions: breakdown by node_type, language, domain, extension (excluding the current taxonomy dimension) - topEntities: top 10 entities by line count with name, type, lines, slug This fixes the empty chart panel on hub/taxonomy pages. Fixes #18
1 parent b14c112 commit 4dba6c0

1 file changed

Lines changed: 54 additions & 3 deletions

File tree

internal/pssg/build/build.go

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,66 @@ func (b *Builder) renderTaxonomyPages(
574574
}
575575

576576
// Hub chart data (same for all pages)
577+
// Build distributions: breakdown by each taxonomy field (except the current one)
578+
distFields := []struct {
579+
Key string
580+
Field string
581+
}{
582+
{"node_type", "node_type"},
583+
{"language", "language"},
584+
{"domain", "domain"},
585+
{"extension", "extension"},
586+
}
587+
distributions := make(map[string][]render.NameCount)
588+
for _, df := range distFields {
589+
if df.Key == tax.Name {
590+
continue // skip the current taxonomy dimension
591+
}
592+
dist := countFieldDistribution(entry.Entities, df.Field, 8)
593+
if len(dist) > 0 {
594+
distributions[df.Key] = dist
595+
}
596+
}
597+
598+
// Build topEntities: largest by line count
599+
type topEntity struct {
600+
Name string `json:"name"`
601+
Type string `json:"type"`
602+
Lines int `json:"lines"`
603+
Slug string `json:"slug"`
604+
}
605+
var topEnts []topEntity
606+
for _, e := range entry.Entities {
607+
lc := e.GetInt("line_count")
608+
if lc > 0 {
609+
topEnts = append(topEnts, topEntity{
610+
Name: e.GetString("title"),
611+
Type: e.GetString("node_type"),
612+
Lines: lc,
613+
Slug: e.Slug,
614+
})
615+
}
616+
}
617+
sort.Slice(topEnts, func(i, j int) bool {
618+
return topEnts[i].Lines > topEnts[j].Lines
619+
})
620+
if len(topEnts) > 10 {
621+
topEnts = topEnts[:10]
622+
}
623+
577624
type hubChart struct {
578-
EntryName string `json:"entryName"`
579-
TotalEntities int `json:"totalEntities"`
580-
TypeDistribution []render.NameCount `json:"typeDistribution"`
625+
EntryName string `json:"entryName"`
626+
TotalEntities int `json:"totalEntities"`
627+
TypeDistribution []render.NameCount `json:"typeDistribution"`
628+
Distributions map[string][]render.NameCount `json:"distributions"`
629+
TopEntities []topEntity `json:"topEntities"`
581630
}
582631
hubChartJSON, _ := json.Marshal(hubChart{
583632
EntryName: entry.Name,
584633
TotalEntities: len(entry.Entities),
585634
TypeDistribution: typeDist,
635+
Distributions: distributions,
636+
TopEntities: topEnts,
586637
})
587638

588639
for page := 1; page <= totalPages; page++ {

0 commit comments

Comments
 (0)