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 currentResults []git.GrepResult ) for _, result := range s.Results { if result.File == currentFile { currentResults = append(currentResults, result) continue } if currentFile != "" { results = append(results, currentResults) } currentFile = result.File currentResults = []git.GrepResult{result} } 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) } } } templ repoSearchResult(repo, ref string, results []git.GrepResult) {