about summary refs log tree commit diff stats
path: root/internal/components/combined.templ
blob: eeacdb527dc3af174f2bb7729dd15461b0c8145f (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
package components

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

templ Combined(result *index.Result) {
	<table>
		<thead>
			<tr>
				<th scope="col">Attribute</th>
				<th scope="col">Description</th>
			</tr>
		</thead>
		<tbody>
			for _, hit := range result.Hits {
				<tr>
					<td>
						@openCombinedDialogLink(nix.GetKey(hit.Data))
					</td>
					<td>
						switch hit.Data.(type) {
							case nix.Option:
								if o := convertMatch[nix.Option](hit.Data); o != nil {
									@markdown(firstSentence(o.Description))
								}
							case nix.Package:
								if o := convertMatch[nix.Package](hit.Data); o != nil {
									{ firstSentence(o.Description) }
								}
						}
					</td>
				</tr>
			}
		</tbody>
	</table>
}