about summary refs log tree commit diff stats
path: root/internal/components/packages.templ
blob: 6e14026ab925635cc53f1f4be521fae22e64c366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package components

import (
	"go.alanpearce.eu/searchix/internal/config"
	"go.alanpearce.eu/searchix/internal/index"
	"go.alanpearce.eu/searchix/internal/nix"
)

templ Packages(result *index.Result) {
	<table>
		<thead>
			<tr>
				<th scope="col">Attribute</th>
				<th scope="col">Name</th>
				<th scope="col">Description</th>
				if config.DevMode {
					<th scope="col">Score</th>
				}
			</tr>
		</thead>
		<tbody>
			for _, hit := range result.Hits {
				if m := convertMatch[nix.Package](hit.Data); m != nil {
					@packageRow(hit, *m)
				}
			}
		</tbody>
	</table>
}

templ packageRow(hit index.DocumentMatch, p nix.Package) {
	<tr>
		<td>
			@openDialogLink(p.Attribute)
		</td>
		<td>
			{ p.Name }
		</td>
		<td>
			{ p.Description }
		</td>
		if config.DevMode {
			<td>
				@score(hit)
			</td>
		}
	</tr>
}