diff options
Diffstat (limited to 'internal/components/optionDetail.templ')
-rw-r--r-- | internal/components/optionDetail.templ | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/internal/components/optionDetail.templ b/internal/components/optionDetail.templ new file mode 100644 index 0000000..52ce859 --- /dev/null +++ b/internal/components/optionDetail.templ @@ -0,0 +1,58 @@ +package components + +import "searchix/internal/nix" + +templ OptionDetail(option nix.Option) { + <h2>{ option.Name }</h2> + @markdown(option.Description) + <dl> + if option.Type != "" { + <dt>Type</dt> + <dd><code>{ option.Type }</code></dd> + } + if option.Default != nil { + if option.Default.Text != "" || option.Default.Markdown != "" { + <dt>Default</dt> + <dd> + if option.Default.Markdown != "" { + @markdown(option.Default.Markdown) + } else { + <pre><code>{ option.Default.Text }</code></pre> + } + </dd> + } + } + if option.Example != nil { + if option.Example.Text != "" || option.Example.Markdown != "" { + <dt>Example</dt> + <dd> + if option.Example.Markdown != "" { + @markdown(option.Example.Markdown) + } else { + <pre><code>{ option.Example.Text }</code></pre> + } + </dd> + } + } + if option.RelatedPackages != "" { + <dt>Related Packages</dt> + <dd> + @markdown(option.RelatedPackages) + </dd> + } + if len(option.Declarations) > 0 { + <dt>Declared</dt> + for _, d := range option.Declarations { + <dd> + <a href={ templ.SafeURL(d.URL) }>{ d.Name }</a> + </dd> + } + } + </dl> +} + +templ OptionDetailPage(tdata TemplateData, option nix.Option) { + @Page(tdata) { + @OptionDetail(option) + } +} |