package html import "fmt" import "go.jolheiser.com/ugit/internal/git" type SearchContext struct { BaseContext RepoHeaderComponentContext Results []git.GrepResult } func (s SearchContext) DedupeResults() [][]git.GrepResult { var ( results [][]git.GrepResult currentFile string ) var idx int for _, result := range s.Results { if result.File == currentFile { results[idx-1] = append(results[idx-1], result) continue } results = append(results, []git.GrepResult{result}) currentFile = result.File idx++ } return results } templ RepoSearch(sc SearchContext) { @base(sc.BaseContext) { @repoHeaderComponent(sc.RepoHeaderComponentContext) for _, results := range sc.DedupeResults() { @repoSearchResult(sc.RepoHeaderComponentContext.Name, sc.RepoHeaderComponentContext.Ref, results) } if len(sc.DedupeResults()) == 0 {
No results
} } } templ repoSearchResult(repo, ref string, results []git.GrepResult) {