about summary refs log tree commit diff stats
path: root/internal/components/options.templ
diff options
context:
space:
mode:
authorAlan Pearce2024-12-31 14:56:37 +0100
committerAlan Pearce2025-01-02 15:05:56 +0100
commit58643f38bdd62dc538a03865b1f81eb77d957779 (patch)
treebf2c5ccce1592ae8bc30508be38510f15fe31b5e /internal/components/options.templ
parent1872c47e393e9c4c811f3b90ec2e0ac4cd8767b2 (diff)
downloadsearchix-58643f38bdd62dc538a03865b1f81eb77d957779.tar.lz
searchix-58643f38bdd62dc538a03865b1f81eb77d957779.tar.zst
searchix-58643f38bdd62dc538a03865b1f81eb77d957779.zip
feat: show scores in results table in dev mode
Diffstat (limited to 'internal/components/options.templ')
-rw-r--r--internal/components/options.templ13
1 files changed, 11 insertions, 2 deletions
diff --git a/internal/components/options.templ b/internal/components/options.templ
index 8e31132..097f66f 100644
--- a/internal/components/options.templ
+++ b/internal/components/options.templ
@@ -1,6 +1,7 @@
 package components
 
 import (
+	"go.alanpearce.eu/searchix/internal/config"
 	"go.alanpearce.eu/searchix/internal/index"
 	"go.alanpearce.eu/searchix/internal/nix"
 )
@@ -11,19 +12,22 @@ templ Options(result *index.Result) {
 			<tr>
 				<th scope="col">Title</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.Option](hit.Data); m != nil {
-					@optionRow(*m)
+					@optionRow(hit, *m)
 				}
 			}
 		</tbody>
 	</table>
 }
 
-templ optionRow(o nix.Option) {
+templ optionRow(hit index.DocumentMatch, o nix.Option) {
 	<tr>
 		<td>
 			@openDialogLink(o.Name)
@@ -32,5 +36,10 @@ templ optionRow(o nix.Option) {
 			@markdown(firstSentence(o.Description))
 			<dialog id={ o.Name }></dialog>
 		</td>
+		if config.DevMode {
+			<td>
+				@score(hit)
+			</td>
+		}
 	</tr>
 }