From fc5fd2edd9b8282497e33a18300eab694d8a89c6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 21 Jun 2024 13:02:08 +0200 Subject: refactor: switch to templ for HTML templates --- internal/components/packageDetail.templ | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 internal/components/packageDetail.templ (limited to 'internal/components/packageDetail.templ') diff --git a/internal/components/packageDetail.templ b/internal/components/packageDetail.templ new file mode 100644 index 0000000..7b4a5cb --- /dev/null +++ b/internal/components/packageDetail.templ @@ -0,0 +1,99 @@ +package components + +import ( + "searchix/internal/nix" +) + +func licenseName(l nix.License) string { + if l.FullName != "" { + return l.FullName + } else { + return l.Name + } +} + +templ PackageDetail(pkg nix.Package) { +

+ if pkg.Broken { + { pkg.Attribute } + } else { + { pkg.Attribute } + } +

+ if pkg.LongDescription != "" { + @markdown(pkg.LongDescription) + } else { +

{ pkg.Description }

+ } +
+ if pkg.MainProgram != "" { +
Main Program
+
+ { pkg.MainProgram } +
+ } + if len(pkg.Homepages) > 0 { +
Homepage
+
+ +
+ } + if pkg.Version != "" { +
Version
+
{ pkg.Version }
+ } + if len(pkg.Licenses) > 0 { +
License
+
+ +
+ } + if len(pkg.Maintainers) > 0 { +
Maintainers
+
+ +
+ } + if pkg.Definition != "" { +
Defined
+
+ Source +
+ } +
+} + +templ PackageDetailPage(tdata TemplateData, pkg nix.Package) { + @Page(tdata) { + @PackageDetail(pkg) + } +} -- cgit 1.4.1