{{ define "repo/fragments/searchResults" }}
{{ if .ErrorMsg }}
{{ i "circle-alert" "size-4" }} {{ .ErrorMsg }}
{{ else }} {{ range .Results }} {{ template "resultCard" . }} {{ else }}
No results found.
{{ end }} {{ end }}
{{ end }} {{ define "resultCard" }} {{ $owner := resolve .Repo.Did }} {{ $slug := .Repo.Slug }} {{ if .File }} {{/* filename match */}}
{{ i "file" "size-4 flex-shrink-0" }} {{- range .File.NameSpans -}} {{- if .Match -}}{{ .Text }} {{- else -}}{{ .Text }}{{- end -}} {{- end -}}
{{ with .Language }} {{ template "repo/fragments/colorBall" (dict "color" (langColor .)) }} {{ . }} {{ end }}
{{ else if .Chunks }} {{/* chunk match */}}
{{ i "file" "size-4 flex-shrink-0" }} {{ .FilePath }}
{{ with .Language }} {{ template "repo/fragments/colorBall" (dict "color" (langColor .)) }} {{ . }} {{ end }}
{{ range $i, $chunk := .Chunks }} {{ if lt $i 3 }} {{ if gt $i 0 }}
···
{{ end }} {{ template "search/fragments/chunkBody" (dict "Owner" $owner "Slug" $slug "Commit" $.Commit "FilePath" $.FilePath "Chunk" $chunk) }} {{ end }} {{ end }} {{ if gt (len .Chunks) 3 }}
{{ i "chevron-down" "size-3 m-1" }} Show {{ (slice .Chunks 3).MatchCount }} more matches
{{ range $i, $chunk := .Chunks }} {{ if ge $i 3 }}
···
{{ template "search/fragments/chunkBody" (dict "Owner" $owner "Slug" $slug "Commit" $.Commit "FilePath" $.FilePath "Chunk" $chunk) }} {{ end }} {{ end }}
{{ end }}
{{ end }} {{ end }}