From a1dfc548198a1326e71f1dd70303a5d3441f7a39 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
+ -
+
+ for _, u := range pkg.Homepages {
+ -
+ { u }
+
+ }
+
+
+ }
+ if pkg.Version != "" {
+ - Version
+ - { pkg.Version }
+ }
+ if len(pkg.Licenses) > 0 {
+ - License
+ -
+
+ for _, l := range pkg.Licenses {
+ -
+ if l.URL != "" {
+ { licenseName(l) }
+ } else {
+ { licenseName(l) }
+ }
+ if l.AppendixURL != "" {
+ Appendix
+ }
+
+ }
+
+
+ }
+ if len(pkg.Maintainers) > 0 {
+ - Maintainers
+ -
+
+ for _, m := range pkg.Maintainers {
+ -
+ if m.Github != "" {
+ { m.Name }
+ } else {
+ { m.Name }
+ }
+
+ }
+
+
+ }
+ if pkg.Definition != "" {
+ - Defined
+ -
+ Source
+
+ }
+
+}
+
+templ PackageDetailPage(tdata TemplateData, pkg nix.Package) {
+ @Page(tdata) {
+ @PackageDetail(pkg)
+ }
+}
--
cgit 1.4.1