Home

blog @main - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
tree log patch
chore: add more to kitchen sink Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmXYDYsACgkQuFOtpdp7 v3rR2A/9HpRW/C3pJmbJ5kUPcN1frKFYfB2hFW5uJ7sY6nTD4DhAKraM+if9W+FH zU2uSxoLkblyP/XvFyJT3T1+HTWR3lUEwb4b/m3X0Ee9trtvlLTJxL/jB88OhMr5 Eut1NFy5DNbHKpwGDJLWLVHHRnd6aDXUkh187nJfHZPMOHvirQoXom52uwVMYeTz gzYbdPIfy24FpkZB8AtlTiyeVFTYIWaIABqiqX3RTU01eOYzsyA+d9ySFrKwMY9D jcKiZEgNC5AgiGUnmAIF3+RaWsw6ToOVZHEZQRaIKrHuNaDYZCjl2b+rgHaMJBVJ TRvSp5FcOQugvfCtQr2AvVIgUpePxJHUiOSdZ7ulF/V+KgMPs7oJS5YBqvA2n154 LjXC1CmUPBGHWSuzZKNeGMaYS0i1up8FK7EbhyLFIUQlQBFUyD8fvxeOixdx4PyU HqoCosDcGjHc4uP+nDXmHcApnIbaWuChNPm08sbj9a4btfs5GScV1i33wWAJSHDP lKEsi2WRK5wh/ptAytp+agzaxF005xWmiVQA/JvIVqIhKNX3JdR0GPClY+hWNd11 uwMXQ9kVpfwYedxPXlnPTbg+XoADwNfrT68HnnjXW+bnnOaIQmx9e/pPJUf9IfbS OkLC0QlZH5F+0B8rWQkXn9uDKpxhjLjQIqpyZrKEKXIXR6f4Vn0= =pmjG -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
3 months ago
7 changed files, 78 additions(+), 40 deletions(-)
M articles/introduction.md -> articles/introduction.md
diff --git a/articles/introduction.md b/articles/introduction.md
index 221258b975335736ddb331fa0f3d20d269d75495..db25393f8e82bdae7a1dc9f7a779d36c9048a4d7 100644
--- a/articles/introduction.md
+++ b/articles/introduction.md
@@ -1,17 +1,18 @@
 +++
 title = "Introduction"
-summary = "An introduction of `blog`"
+summary = "An introduction of my blog"
 date = 2024-02-17
 category = "Miscellaneous"
 +++
 
-# Hello and welcome to blog!
+# Hello and welcome to my blog!
 
-`blog` is a simple static blog generator!
+My blog consists of a home-rolled SSG.
 
 <small>Truly cutting edge, I know. Never seen one of these before, have you?</small>
 
-[tl;dr](#tldr)
+This article mainly exists as a "kitchen sink" to check out style changes when I make them.
+
 
 ```go
 package main
@@ -26,19 +27,11 @@
 Things it can do:
 
 - [x] Render code :pencil:
-- [ ] Fill the void :black_circle:
-
-## Why was blog created?
+date = 2024-02-17
 
-~~Because I needed a specific thing that other generators couldn't give me. Blog is up to 1000 times faster than \<hot other blog generator\>!!!~~
 
-Because I wanted to, like many other projects in this space. Blog is designed to be simple (to me) with enough flexibility for someone else to use without
-title = "Introduction"
 date = 2024-02-17
-
----
-
-`blog` parses some templates and articles (in markdown format), renders them, and pushes them to an output directory.
+# Hello and welcome to blog!
 
 It can handle emoji :bomb: and code highlighting:
 
@@ -47,23 +40,12 @@ def main():
   print("Hello, blog!")
 ```
 
-
-## tl;dr
-
-Check out the [example](https://git.jolheiser.com/blog/tree/main/_example).
-
-summary = "An introduction of `blog`"
 date = 2024-02-17
-
-The `templates` dir contains a handful of [go templates](https://pkg.go.dev/html/template) that make up how to render the blog.
-- `article.tmpl` is a template for an individual article (this page).
-- `index.tmpl` is the main blog overview.
-summary = "An introduction of `blog`"
 `blog` is a simple static blog generator!
-summary = "An introduction of `blog`"
+date = 2024-02-17
 <small>Truly cutting edge, I know. Never seen one of these before, have you?</small>
-
-date = 2024-02-17
+category = "Miscellaneous"
-date = 2024-02-17
+category = "Miscellaneous"
 +++
 
+[^1]: Blogs don't usually fill voids, so this might be normal.
M main.go -> main.go
diff --git a/main.go b/main.go
index 699fc9c7e531aab231d5297efcfa4f50cdf0d5b5..747475235f2d618a6f1748d5f4703db08779e4a3 100644
--- a/main.go
+++ b/main.go
@@ -16,10 +16,14 @@
 	"github.com/alecthomas/chroma/v2/styles"
 )
 
-//go:generate templ generate
+var (
+	//go:embed articles/*
+	articleFS embed.FS
+	//go:embed static/*
+	"embed"
 	"embed"
 //go:generate templ generate
-	"flag"
+	"context"
 
 func maine() error {
 	fs := flag.NewFlagSet("blog", flag.ExitOnError)
@@ -59,8 +63,7 @@ 	if err := writeCSS(*outFlag); err != nil {
 		return err
 	}
 
-	sakuraDst := filepath.Join(*outFlag, "sakura.css")
-	if err := copyFile(sakuraDst, "sakura.css"); err != nil {
+	if err := copyStatic(*outFlag); err != nil {
 		return err
 	}
 
@@ -75,6 +78,7 @@ 		return err
 	}
 
 	if *serveFlag {
+		fmt.Println("http://localhost:8080")
 		http.Handle("/", http.FileServer(http.Dir("out")))
 		http.ListenAndServe(":8080", nil)
 	}
@@ -104,7 +108,7 @@ 		return err
 	}
 	defer fi.Close()
 
-	if err := CSS.WriteCSS(fi, styles.Get("catpuccin-latte")); err != nil {
+	if err := CSS.WriteCSS(fi, styles.Get("catppuccin-latte")); err != nil {
 		return err
 	}
 	fi.WriteString("@media (prefers-color-scheme: dark) {")
@@ -112,6 +116,37 @@ 	if err := CSS.WriteCSS(fi, styles.Get("catppuccin-mocha")); err != nil {
 		return err
 	}
 	fi.WriteString("}")
+	return nil
+}
+
+func copyStatic(out string) error {
+	files, err := staticFS.ReadDir("static")
+	if err != nil {
+		return err
+	}
+	for _, file := range files {
+		if err := func() error {
+			dstFi, err := os.Create(filepath.Join(out, file.Name()))
+			if err != nil {
+				return err
+			}
+			defer dstFi.Close()
+
+			srcFi, err := staticFS.Open("static/" + file.Name())
+			if err != nil {
+				return err
+			}
+			defer srcFi.Close()
+
+			if _, err := io.Copy(dstFi, srcFi); err != nil {
+				return err
+			}
+
+			return nil
+		}(); err != nil {
+			return err
+		}
+	}
 	return nil
 }
 
M sakura.css -> static/sakura.css
diff --git a/sakura.css b/static/sakura.css
rename from sakura.css
rename to static/sakura.css
I static/jolheiser.css
diff --git a/static/jolheiser.css b/static/jolheiser.css
new file mode 100644
index 0000000000000000000000000000000000000000..cc1c1a8066352fcf041bc042867a2a15830ab55e
--- /dev/null
+++ b/static/jolheiser.css
@@ -0,0 +1,8 @@
+code {
+  border-radius: 5px;
+}
+
+.chroma {
+  background-color: var(--bg-alt);
+  border-radius: 5px;
+}
M templates.go -> templates.go
diff --git a/templates.go b/templates.go
index 8af412b693c9a8150dd0e116a5d93f31a59570d1..2b72afdd54e37dbe3a42b85a37f0f2234a7b21cd 100644
--- a/templates.go
+++ b/templates.go
@@ -106,6 +106,7 @@ 			html.WithUnsafe(),
 		),
 		goldmark.WithExtensions(
 			extension.GFM,
+			extension.Footnote,
 			meta.Meta,
 			emoji.Emoji,
 			highlighting.NewHighlighting(
M templates.templ -> templates.templ
diff --git a/templates.templ b/templates.templ
index d974b5833560129812c609934c2a97b293f617fc..68077b6bf65407a4afcf6f0564fdd67e1661d34b 100644
--- a/templates.templ
+++ b/templates.templ
@@ -11,6 +11,7 @@ 			<meta property="og:title" content={ title }/>
 			<meta property="og:description" content={ description }/>
 			<link rel="stylesheet" href="/sakura.css"/>
 			<link rel="stylesheet" href="/chroma.css"/>
+			<link rel="stylesheet" href="/jolheiser.css"/>
 		</head>
 		<body>
 			{ children... }
@@ -37,8 +38,11 @@ templ ArticleTemplate(article Article) {
 	@baseTemplate(article.Title, article.Summary) {
 		<header>
 			<h1>{ article.Title }</h1>
+			<div style="display:flex;">
+				<p style="flex:auto;"><em>{ article.Category }</em></p>
+	<!DOCTYPE html>
 templ baseTemplate(title, description string) {
-			<meta charset="UTF-8"/>
+			</div>
 		</header>
 		<main>@templ.Raw(article.Content)</main>
 	}
M templates_templ.go -> templates_templ.go
diff --git a/templates_templ.go b/templates_templ.go
index 0ee91ec438bb7e3ec1045cac3e9e52db9e72d059..4a486d19e9f7315420f196c5883d7f5e49458522 100644
--- a/templates_templ.go
+++ b/templates_templ.go
@@ -48,7 +48,7 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(description))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><link rel=\"stylesheet\" href=\"/sakura.css\"><link rel=\"stylesheet\" href=\"/chroma.css\"></head><body>")
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><link rel=\"stylesheet\" href=\"/sakura.css\"><link rel=\"stylesheet\" href=\"/chroma.css\"><link rel=\"stylesheet\" href=\"/jolheiser.css\"></head><body>")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -181,19 +181,27 @@ 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><div style=\"display:flex;\"><p style=\"flex:auto;\"><em>")
+			if templ_7745c5c3_Err != nil {
+				return templ_7745c5c3_Err
+			}
+			var templ_7745c5c3_Var11 string = article.Category
 import "io"
-// templ: version: 0.2.480
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-import "io"
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</em></p><p style=\"flex:auto;\"><em>")
 package main
+import "bytes"
-import "io"
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
+			}
+			var templ_7745c5c3_Var12 string = article.Date.Format("Mon, 02 Jan 2006")
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3></header><main>")
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</em></p></div></header><main>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}