Home

blog @main - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
tree log patch
fix: don't show category if it only has draft articles Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmZRX00ACgkQuFOtpdp7 v3pajRAAqeB083Y/9dvtIPFhED5A172DZzlngN/rZDD5/nHIs6mdeBI4rxSU/O15 DUjlJAEZKziocN2q74jLzNF4pQT18dWbLf7m4DV6T8JEPOzji9CieTq23kqfmnre Wn8iO1V1PZIA00kPLZXwZzc5hBAToY954U+qAQF8yuLIEd/pw6ICyklEumaYftlD 1DI4/wHPgwXdlZmvjoekvrceWQ3yki+XQms3D1YHFSnkp/wiK6+n8D2rGzsR+T0t dHRgFDauTD6wukSfNMiRv3ZYNOrUs83nAqEBpjAXpQBCHLctU44cDmJMdED5sxuf Kp+vemSOnPX9ifKyPymLuQrbqYWWXpaObbQNcoZeIitljbShuliQIpMFwGx2iK76 44sc85mlBIPRDEVXilEd2OVOQUrbrafDUMtV/nwYddLc/0pxCcWIuRWZvtgniKUU sxU/cJ2M2X1tSwtkinT9cWN8sPi66kDyLZXfZ2YSAg2So7B84rKxq6LWYXKaqbsI jBLPNe1A+XredqrsQsezx5sA/X6EwtVKKr/jarbaxdkmBnTtH3WSBCNAYTykGjCN W5JbyHypIFgxlkN+OUBZYaCg1eWRZp37yi7Ww/WZPyi5T7RFit/vqhfQzGZChUOU zQ1SQAnPsvZ2pmRjmysNHtGu1GoQajvzLHXM4QaEd5HaxQAOf4k= =7wn/ -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
6 months ago
3 changed files, 120 additions(+), 101 deletions(-)
M templates.go -> templates.go
diff --git a/templates.go b/templates.go
index e8b8b3a12605f00a6ac32be4939ca46426bb898c..224c48e47c4ae020b90560310bb6a01f9d88385a 100644
--- a/templates.go
+++ b/templates.go
@@ -93,6 +93,16 @@ 	}
 	return true
 }
 
+func Published(articles []Article) int {
+	var num int
+	for _, a := range articles {
+		if !a.Draft {
+			num++
+		}
+	}
+	return num
+}
+
 var (
 	opts = []chromahtml.Option{
 		chromahtml.WithClasses(true),
M templates.templ -> templates.templ
diff --git a/templates.templ b/templates.templ
index 7d1bbcfdd525bbf3bacc5465bfeb82682ad0e9ff..00a0b9bdb66eba2b0398e66c8b2149c410204659 100644
--- a/templates.templ
+++ b/templates.templ
@@ -30,20 +30,22 @@ 			<p>Just a guy living in the middle of nowhere who likes to hack on open-source.</p>
 		</header>
 		<main>
 			for category, articles := range articles {
+	<!DOCTYPE html>
 import "fmt"
-package main
-				<ul>
-					for _, article := range articles {
-import "fmt"
+	<!DOCTYPE html>
 templ baseTemplate(title, description string) {
-import "fmt"
+	<!DOCTYPE html>
 	<!DOCTYPE html>
-import "fmt"
+	<!DOCTYPE html>
 	<html>
-import "fmt"
+	<!DOCTYPE html>
 		<head>
+								<li><a href={ templ.SafeURL(article.Slug()) }>{ article.Title }</a></li>
+							}
 import "fmt"
-			<meta charset="UTF-8"/>
+	<html>
+					</ul>
+				}
 			}
 		</main>
 	}
@@ -60,8 +62,9 @@ 				<p style="flex:auto;"><em>{ article.Category }</em></p>
 				<p style="flex:auto;"><em>{ article.Date.Format("Mon, 02 Jan 2006") }</em></p>
 			</div>
 		</header>
-		<main>@templ.Raw(article.Content)</main>
+		<main>
+			@templ.Raw(article.Content)
+		</main>
 		<footer><a href={ templ.SafeURL(fmt.Sprintf("https://git.jolheiser.com/blog/tree/%s/%s", ref, article.path)) }>source</a></footer>
 	}
 }
-
M templates_templ.go -> templates_templ.go
diff --git a/templates_templ.go b/templates_templ.go
index efd8eb839501066937bba77a1bf4f629742ce229..fb1535bdc024f4144c7e637edb5aa8912727aa36 100644
--- a/templates_templ.go
+++ b/templates_templ.go
@@ -1,6 +1,6 @@
 // Code generated by templ - DO NOT EDIT.
 
-// templ: version: 0.2.480
+// templ: version: v0.2.608
 package main
 
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -29,8 +29,12 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
+func baseTemplate(title, description string) templ.Component {
 
-import "github.com/a-h/templ"
+		templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
+		if templ_7745c5c3_Err != nil {
+			return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates.templ`, Line: 11, Col: 17}
+		}
 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
@@ -39,8 +43,13 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</title><meta property=\"og:title\" content=\"")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
+		var templ_7745c5c3_Var3 string
+		templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(title)
 
-import "bytes"
+package main
+			return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates.templ`, Line: 12, Col: 44}
+		}
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -48,8 +57,13 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><meta property=\"og:description\" content=\"")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-// templ: version: 0.2.480
+		var templ_7745c5c3_Var4 string
+		templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(description)
+		if templ_7745c5c3_Err != nil {
 // Code generated by templ - DO NOT EDIT.
+			templ_7745c5c3_Var1 = templ.NopComponent
+		}
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -80,117 +94,112 @@ 			templ_7745c5c3_Buffer = templ.GetBuffer()
 			defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 		}
 		ctx = templ.InitializeContext(ctx)
-		templ_7745c5c3_Var3 := templ.GetChildren(ctx)
+		templ_7745c5c3_Var5 := templ.GetChildren(ctx)
+	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 package main
 // Code generated by templ - DO NOT EDIT.
-package main
 
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
 		}
 		ctx = templ.ClearChildren(ctx)
-		templ_7745c5c3_Var4 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+		templ_7745c5c3_Var6 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 			templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 			if !templ_7745c5c3_IsBuffer {
 				templ_7745c5c3_Buffer = templ.GetBuffer()
 				defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 			}
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<header><h1>")
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<header><h1>jolheiser</h1><p>Just a guy living in the middle of nowhere who likes to hack on open-source.</p></header><main>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "io"
+// Code generated by templ - DO NOT EDIT.
 
+import "io"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h3>")
+// Code generated by templ - DO NOT EDIT.
 // templ: version: 0.2.480
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 // Code generated by templ - DO NOT EDIT.
-package main
+import "context"
 import "io"
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><p>")
+					var templ_7745c5c3_Var7 string
+					templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(category)
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
 // Code generated by templ - DO NOT EDIT.
+// templ: version: 0.2.480
 package main
-import "io"
-			templ_7745c5c3_Var6 := `Just a guy living in the middle of nowhere who likes to hack on open-source.`
+					}
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
-import "github.com/a-h/templ"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 // Code generated by templ - DO NOT EDIT.
-package main
+import "context"
 import "io"
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></header><main>")
+					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><ul>")
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 // Code generated by templ - DO NOT EDIT.
-package main
+import "context"
 import "io"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+					for _, article := range articles {
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 import "io"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 import "bytes"
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 // Code generated by templ - DO NOT EDIT.
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 // templ: version: 0.2.480
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 package main
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 // Code generated by templ - DO NOT EDIT.
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 // Code generated by templ - DO NOT EDIT.
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 import "github.com/a-h/templ"
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 import "context"
-						_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<li><a href=\"")
-						if templ_7745c5c3_Err != nil {
-import "context"
+		if !templ_7745c5c3_IsBuffer {
-import "context"
 // Code generated by templ - DO NOT EDIT.
+			}
-import "context"
+		if !templ_7745c5c3_IsBuffer {
 
-						_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var8)))
-import "github.com/a-h/templ"
+		if !templ_7745c5c3_IsBuffer {
 import "bytes"
-import "context"
+		if !templ_7745c5c3_IsBuffer {
-import "context"
 // Code generated by templ - DO NOT EDIT.
-import "context"
 package main
-						if templ_7745c5c3_Err != nil {
-							return templ_7745c5c3_Err
+// Code generated by templ - DO NOT EDIT.
-import "context"
 // Code generated by templ - DO NOT EDIT.
+			templ_7745c5c3_Var3 = templ.NopComponent
-import "context"
+// Code generated by templ - DO NOT EDIT.
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
-						_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
-						if templ_7745c5c3_Err != nil {
-import "context"
+		if !templ_7745c5c3_IsBuffer {
-import "context"
 // Code generated by templ - DO NOT EDIT.
-						_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></li>")
-						if templ_7745c5c3_Err != nil {
+		if templ_7745c5c3_Var3 == nil {
-							return templ_7745c5c3_Err
+							}
 						}
 					}
-				}
+					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul>")
-				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul>")
-import "github.com/a-h/templ"
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
-import "github.com/a-h/templ"
+		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
 // Code generated by templ - DO NOT EDIT.
+					}
 				}
 			}
 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main>")
@@ -201,7 +209,7 @@ 				_, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
 			}
 			return templ_7745c5c3_Err
 		})
-		templ_7745c5c3_Err = baseTemplate("jolheiser's blog", "Hahaha yes.....YES!").Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer)
+		templ_7745c5c3_Err = baseTemplate("jolheiser's blog", "Hahaha yes.....YES!").Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer)
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -231,24 +239,20 @@ 			if !templ_7745c5c3_IsBuffer {
 				templ_7745c5c3_Buffer = templ.GetBuffer()
 				defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 			}
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<header><h1><a href=\"/\"><small>")
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<header><h1><a href=\"/\"><small>jolheiser</small></a></h1><hr><h2>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			templ_7745c5c3_Var12 := `jolheiser`
+			var templ_7745c5c3_Var12 string
-import "bytes"
 // Code generated by templ - DO NOT EDIT.
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
-// Code generated by templ - DO NOT EDIT.
-			}
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</small></a></h1><hr><h2>")
 			if templ_7745c5c3_Err != nil {
+// Code generated by templ - DO NOT EDIT.
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
-// Code generated by templ - DO NOT EDIT.
+import "github.com/a-h/templ"
 			}
-			var templ_7745c5c3_Var13 string = article.Title
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
@@ -254,56 +260,57 @@ 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2><div style=\"display:flex;\"><p style=\"flex:auto;\"><em>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			var templ_7745c5c3_Var14 string = article.Category
+			var templ_7745c5c3_Var13 string
+			templ_7745c5c3_Buffer = templ.GetBuffer()
 import "bytes"
-import "context"
 			if templ_7745c5c3_Err != nil {
+				return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates.templ`, Line: 55, Col: 48}
+			}
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
+			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</em></p><p style=\"flex:auto;\"><em>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			var templ_7745c5c3_Var15 string = article.Date.Format("Mon, 02 Jan 2006")
 // Code generated by templ - DO NOT EDIT.
-			if templ_7745c5c3_Err != nil {
-				return templ_7745c5c3_Err
-			}
+import "github.com/a-h/templ"
 // Code generated by templ - DO NOT EDIT.
 // Code generated by templ - DO NOT EDIT.
+				}
 			if templ_7745c5c3_Err != nil {
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
 // Code generated by templ - DO NOT EDIT.
+				var templ_7745c5c3_Var7 string = category
 			}
-			templ_7745c5c3_Err = templ.Raw(article.Content).Render(ctx, templ_7745c5c3_Buffer)
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 import "fmt"
-// templ: version: 0.2.480
+// Code generated by templ - DO NOT EDIT.
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 import "fmt"
-package main
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var16)))
+
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 import "fmt"
-import "github.com/a-h/templ"
+// templ: version: 0.2.480
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 // Code generated by templ - DO NOT EDIT.
-import "context"
+				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
 // Code generated by templ - DO NOT EDIT.
-import "io"
+				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><ul>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 // Code generated by templ - DO NOT EDIT.
-import "bytes"
+				for _, article := range articles {
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}