all repos — searchix @ 896d844cac976afd0ee8aa73dd2fb28e15e7ac79

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: Convert templ components to gomponents

Alan Pearce
commit

896d844cac976afd0ee8aa73dd2fb28e15e7ac79

parent

1183108baa44fde88944e9207fb7763668c2b448

1 file changed, 71 insertions(+), 0 deletions(-)

changed files
A internal/components/optionDetail.go
@@ -0,0 +1,71 @@
+package components + +import ( + "go.alanpearce.eu/searchix/internal/nix" + + g "go.alanpearce.eu/gomponents" + . "go.alanpearce.eu/gomponents/html" +) + +func OptionDetail(option nix.Option) g.Node { + return g.Group([]g.Node{ + H2(g.Text(option.Name)), + option.Description, + Dl( + g.If(option.Type != "", + g.Group([]g.Node{ + Dt(g.Text("Type")), + Dd(Code(g.Text(option.Type))), + }), + ), + g.Iff(option.Default != nil, + func() g.Node { + return g.Group([]g.Node{ + Dt(g.Text("Default")), + Dd( + g.If(option.Default.Markdown != "", + option.Default.Markdown, + Pre(Code(g.Text(option.Default.Text))), + ), + ), + }) + }, + ), + g.Iff(option.Example != nil, + func() g.Node { + return g.Group([]g.Node{ + Dt(g.Text("Example")), + Dd( + g.If(option.Example.Markdown != "", + option.Example.Markdown, + Pre(Code(g.Text(option.Example.Text))), + ), + ), + }) + }, + ), + g.If(option.RelatedPackages != "", + g.Group([]g.Node{ + Dt(g.Text("Related Packages")), + Dd( + option.RelatedPackages, + ), + }), + ), + g.If(len(option.Declarations) > 0, + g.Group([]g.Node{ + Dt(g.Text("Declared")), + g.Map(option.Declarations, func(d nix.Link) g.Node { + return Dd( + A(Href(d.URL), g.Text(d.Name)), + ) + }), + }), + ), + ), + }) +} + +func OptionDetailPage(tdata TemplateData, option nix.Option) g.Node { + return Page(tdata, OptionDetail(option)) +}