package html import ( "fmt" "strings" "path" ) type RepoBreadcrumbComponentContext struct { Repo string Ref string Path string } type breadcrumb struct { label string href string end bool } func (r RepoBreadcrumbComponentContext) crumbs() []breadcrumb { parts := strings.Split(r.Path, "/") breadcrumbs := []breadcrumb{ { label: r.Repo, href: fmt.Sprintf("/%s/tree/%s/", r.Repo, r.Ref), }, } for idx, part := range parts { breadcrumbs = append(breadcrumbs, breadcrumb{ label: part, href: path.Join(breadcrumbs[idx].href, part), }) } breadcrumbs[len(breadcrumbs)-1].end = true return breadcrumbs } templ repoBreadcrumbComponent(rbcc RepoBreadcrumbComponentContext) { if rbcc.Path != "" {