diff options
author | Alan Pearce | 2024-06-21 13:02:08 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-21 15:44:12 +0200 |
commit | a1dfc548198a1326e71f1dd70303a5d3441f7a39 (patch) | |
tree | 03e7d60dc389678ee7cadaac4d5e64596dffde91 /internal/components/optionDetail.templ | |
parent | cac323d9ae70f55a43fd99b73e60cf614be11797 (diff) | |
download | searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.lz searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.zst searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.zip |
refactor: switch to templ for HTML templates
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) + } +} |