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) {
{ results[0].File }
@templ.Raw(results[0].Content)
if len(results) > 1 {
{ fmt.Sprintf("%d ", len(results[1:])) }more for _, result := range results[1:] {
{ results[0].File }
@templ.Raw(result.Content)
}
} }