diff options
Diffstat (limited to 'internal/components/optionDetail.go')
-rw-r--r-- | internal/components/optionDetail.go | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/internal/components/optionDetail.go b/internal/components/optionDetail.go new file mode 100644 index 0000000..d5f0c24 --- /dev/null +++ b/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)) +} |