internal/components/optionDetail.go (view raw)
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | package components
import (
"alin.ovh/searchix/internal/nix"
g "alin.ovh/gomponents"
. "alin.ovh/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.Plain))),
),
),
})
},
),
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.Plain))),
),
),
})
},
),
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)),
)
}),
}),
),
),
})
}
|