Home

blog @main - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
tree log patch
feat: atom feed and more on index Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmXcB+AACgkQuFOtpdp7 v3r0lg//TVL4EkYPs9pHqKzpdvp4TWbA1ug/0ZTbksJ96vGDVeXbIYTLEOdseDr5 9CBBR4lBabxLYaiVJfUmmpHDqCAqdP2SmL4QCq0wdqmvcjeO7izkIU6o5/prEMVd O2gqT25QrPWzd2TMmaTWG3+WsPn6BTBzOCD6pTESFWRWX4nIuCuthIklVnTDkecD lUlr0SW9J+8CvX6fD/qAUw0s4CWkfTzUxAeo4p5UKdjCK4sVqbSI61V/mIIq+Bxx l1gQ2k/4qt935bU1oTqcqqRQHDK4f+ozZrvvo2t6xELKJUngEUEEeVe2ZK1D1sVB BfjYYe0lS4Qrxht0KKxkiLSCf+QLpkarSJbaiXflysMA0tcgIG/LT3vTU9++4uqJ YaS75HWT5USw+DMd2p9T6qkfgSmet+W4Fw3SRCm1IsTKiskVl/yqCFoG4yP22U2+ 6sa6UGTpJcRIPKDDariZuB29/dHA1sgJiq5PIrvRMNNatlxmjuSWR6rMHldbT8ZC 0z2pNn6G/6dqFZuvUwIdLVNGcLv/Zw1VLb9AB+LIas5lZacHAP1zFsyXiF/aIK0Z E8fOqIjtmPjTUTZSkgxM4Kva+/dPoa5TQL9ic1Zbvx+J7Iy8mehp9FnTjY+F7UOG peH+zZjupFtNe/GKdDYMUBg0DPx6tsH8bltc/B3F2BRZggJYTr4= =nRw4 -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
3 months ago
6 changed files, 98 additions(+), 28 deletions(-)
M articles/introduction.md -> articles/introduction.md
diff --git a/articles/introduction.md b/articles/introduction.md
index db25393f8e82bdae7a1dc9f7a779d36c9048a4d7..eb8540e3c1961a07939e4274b3c74a60f1a5d8d9 100644
--- a/articles/introduction.md
+++ b/articles/introduction.md
@@ -28,6 +28,9 @@ Things it can do:
 
 - [x] Render code :pencil:
 - [ ] Fill the void[^1] :black_circle:
+- [x] Generate an [~~RSS~~ Atom Feed](/feed.atom)
+
+> atom is like rss, but better (??), but not all feeds support it, but a lot do, but rss is more widely supported, but most people use atom, except for the people who use rss, which is probably more
 
 `blog` parses some articles (in markdown format), renders them, and pushes them to an output directory.
 
M go.mod -> go.mod
diff --git a/go.mod b/go.mod
index 3d226dae1f71f357af8b8c8cbd8f38889bcba113..3270f56fe5a500bc0270341295be4dbab205c200 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ require (
 	github.com/BurntSushi/toml v1.3.2
 	github.com/a-h/templ v0.2.543
 	github.com/alecthomas/chroma/v2 v2.12.0
+	github.com/gorilla/feeds v1.1.2
 	github.com/yuin/goldmark v1.7.0
 	github.com/yuin/goldmark-emoji v1.0.2
 	github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
@@ -14,7 +15,6 @@ )
 
 require (
 	github.com/dlclark/regexp2 v1.10.0 // indirect
-	github.com/kr/pretty v0.3.1 // indirect
 	gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
 	gopkg.in/yaml.v2 v2.4.0 // indirect
 )
M go.sum -> go.sum
diff --git a/go.sum b/go.sum
index c4b1bc6fb037c92e5fe68ac1efae39f51b36f823..b6480dd6af6a990164073d9407775bc0744bff4a 100644
--- a/go.sum
+++ b/go.sum
@@ -11,8 +11,6 @@ github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
 github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
 github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
 github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
-github.com/a-h/templ v0.2.543 h1:8YyLvyUtf0/IE2nIwZ62Z/m2o2NqwhnMynzOL78Lzbk=
-github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
 github.com/a-h/templ v0.2.543/go.mod h1:jP908DQCwI08IrnTalhzSEH9WJqG/Q94+EODQcJGFUA=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
@@ -21,13 +19,14 @@ github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
 github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
 github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/gorilla/feeds v1.1.2 h1:pxzZ5PD3RJdhFH2FsJJ4x6PqMqbgFk1+Vez4XWBW8Iw=
+github.com/gorilla/feeds v1.1.2/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
 github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
 github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
 github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
 github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
 github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
M main.go -> main.go
diff --git a/main.go b/main.go
index 747475235f2d618a6f1748d5f4703db08779e4a3..30ad19e2132b20ea77ecc5ef7c77ac4ca4c87858 100644
--- a/main.go
+++ b/main.go
@@ -12,8 +12,10 @@ 	iofs "io/fs"
 	"net/http"
 	"os"
 	"path/filepath"
+	"time"
 
 	"github.com/alecthomas/chroma/v2/styles"
+	"github.com/gorilla/feeds"
 )
 
 var (
@@ -38,7 +40,8 @@ 	if err != nil {
 		return err
 	}
 
-	articles := make(Articles)
+	categories := make(Articles)
+	articles := make([]Article, 0, len(files))
 	for _, file := range files {
 		if filepath.Ext(file.Name()) != ".md" {
 			continue
@@ -51,8 +54,9 @@ 		article, err := Parse(string(content))
 		if err != nil {
 			return err
 		}
+		categories[article.Category] = append(categories[article.Category], article)
+	"fmt"
 
-//go:generate go run .
 		if err := writeArticle(*outFlag, article); err != nil {
 			return err
 		}
@@ -66,13 +70,17 @@ 	if err := copyStatic(*outFlag); err != nil {
 		return err
 	}
 
+	if err := writeRSS(*outFlag, articles); err != nil {
+		return err
+	}
+
 	fi, err := os.Create(filepath.Join(*outFlag, "index.html"))
 	if err != nil {
 		return err
 	}
 	defer fi.Close()
 
-	if err := IndexTemplate(articles).Render(context.Background(), fi); err != nil {
+	if err := IndexTemplate(categories).Render(context.Background(), fi); err != nil {
 		return err
 	}
 
@@ -98,6 +106,40 @@ 	}
 	defer fi.Close()
 
 	return ArticleTemplate(article).Render(context.Background(), fi)
+}
+
+func writeRSS(out string, articles []Article) error {
+	fi, err := os.Create(filepath.Join(out, "feed.atom"))
+	if err != nil {
+		return err
+	}
+	defer fi.Close()
+
+	feed := &feeds.Feed{
+		Title:       "jolheiser",
+		Link:        &feeds.Link{Href: "https://blog.jolheiser.com"},
+		Description: "jolheiser's blog log in a blog bog",
+		Author: &feeds.Author{
+			Name:  "John Olheiser",
+			Email: "john@jolheiser.com",
+		},
+		Updated: time.Now(),
+		Created: time.Date(2024, time.February, 25, 0, 0, 0, 0, time.Local),
+		// Image:       &feeds.Image{},
+	}
+	for _, article := range articles {
+		url := fmt.Sprintf("https://blog.jolheiser.com/%s", article.Slug())
+		feed.Items = append(feed.Items, &feeds.Item{
+			Title:       article.Title,
+			Link:        &feeds.Link{Href: url},
+			Description: article.Summary,
+			Id:          url,
+			Created:     article.Date,
+			// Content:     article.Content,
+		})
+	}
+
+	return feed.WriteAtom(fi)
 }
 
 func writeCSS(out string) error {
M templates.templ -> templates.templ
diff --git a/templates.templ b/templates.templ
index 68077b6bf65407a4afcf6f0564fdd67e1661d34b..173aac3f47e4500e84ada5cc6d3274e1a2cef611 100644
--- a/templates.templ
+++ b/templates.templ
@@ -9,6 +9,7 @@ 			<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
 			<title>{ title }</title>
 			<meta property="og:title" content={ title }/>
 			<meta property="og:description" content={ description }/>
+			<link rel="alternate" type="application/atom+xml" href="/feed.atom"/>
 			<link rel="stylesheet" href="/sakura.css"/>
 			<link rel="stylesheet" href="/chroma.css"/>
 			<link rel="stylesheet" href="/jolheiser.css"/>
@@ -21,9 +22,13 @@ }
 
 templ IndexTemplate(articles Articles) {
 	@baseTemplate("jolheiser's blog", "Hahaha yes.....YES!") {
+		<header>
+			<h1>jolheiser</h1>
+			<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 {
-				<h2>{ category }</h2>
+				<h3>{ category }</h3>
 				<ul>
 					for _, article := range articles {
 						<li><a href={ templ.SafeURL(article.Slug()) }>{ article.Title }</a></li>
M templates_templ.go -> templates_templ.go
diff --git a/templates_templ.go b/templates_templ.go
index 4a486d19e9f7315420f196c5883d7f5e49458522..7d6b98107fbc6e667247845a3859e5ba9f6c82fc 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\"><link rel=\"stylesheet\" href=\"/jolheiser.css\"></head><body>")
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><link rel=\"alternate\" type=\"application/atom+xml\" href=\"/feed.atom\"><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
 		}
@@ -86,22 +86,41 @@ 			if !templ_7745c5c3_IsBuffer {
 				templ_7745c5c3_Buffer = templ.GetBuffer()
 				defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 			}
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<header><h1>")
 package main
+import "bytes"
+				return templ_7745c5c3_Err
+			}
+			templ_7745c5c3_Var5 := `jolheiser`
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
+			if templ_7745c5c3_Err != nil {
+				return templ_7745c5c3_Err
+			}
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><p>")
+			if templ_7745c5c3_Err != nil {
+				return templ_7745c5c3_Err
+			}
+			templ_7745c5c3_Var6 := `Just a guy living in the middle of nowhere who likes to hack on open-source.`
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
+			if templ_7745c5c3_Err != nil {
+				return templ_7745c5c3_Err
+			}
+import "bytes"
 import "io"
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 			for category, articles := range articles {
-				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2>")
+				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h3>")
 				if templ_7745c5c3_Err != nil {
 					return templ_7745c5c3_Err
 				}
-				var templ_7745c5c3_Var5 string = category
+				var templ_7745c5c3_Var7 string = category
-				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
+				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
 				if templ_7745c5c3_Err != nil {
 					return templ_7745c5c3_Err
 				}
-				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2><ul>")
+				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><ul>")
 				if templ_7745c5c3_Err != nil {
 					return templ_7745c5c3_Err
 				}
@@ -110,8 +129,8 @@ 					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<li><a href=\"")
 					if templ_7745c5c3_Err != nil {
 						return templ_7745c5c3_Err
 					}
-					var templ_7745c5c3_Var6 templ.SafeURL = templ.SafeURL(article.Slug())
+					var templ_7745c5c3_Var8 templ.SafeURL = templ.SafeURL(article.Slug())
-					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var6)))
+					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var8)))
 					if templ_7745c5c3_Err != nil {
 						return templ_7745c5c3_Err
 					}
@@ -119,9 +138,9 @@ 					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
 					if templ_7745c5c3_Err != nil {
 						return templ_7745c5c3_Err
 					}
-					var templ_7745c5c3_Var7 string = article.Title
+					var templ_7745c5c3_Var9 string = article.Title
+func baseTemplate(title, description string) templ.Component {
 import "github.com/a-h/templ"
-import "io"
 					if templ_7745c5c3_Err != nil {
 						return templ_7745c5c3_Err
 					}
@@ -163,15 +182,16 @@ 			templ_7745c5c3_Buffer = templ.GetBuffer()
 			defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
 		}
 		ctx = templ.InitializeContext(ctx)
+func baseTemplate(title, description string) templ.Component {
 import "context"
-import "github.com/a-h/templ"
-		if templ_7745c5c3_Var8 == nil {
-import "context"
+func baseTemplate(title, description string) templ.Component {
 import "io"
 // Code generated by templ - DO NOT EDIT.
+import "bytes"
+// Code generated by templ - DO NOT EDIT.
 import "github.com/a-h/templ"
 		ctx = templ.ClearChildren(ctx)
-		templ_7745c5c3_Var9 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+		templ_7745c5c3_Var11 := 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()
@@ -181,10 +201,10 @@ 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<header><h1>")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-import "io"
+	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
 // Code generated by templ - DO NOT EDIT.
 import "io"
-
+import "io"
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
@@ -192,8 +212,8 @@ 			_, 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
+			var templ_7745c5c3_Var13 string = article.Category
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
@@ -201,8 +221,8 @@ 			_, 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_Var12 string = article.Date.Format("Mon, 02 Jan 2006")
+			var templ_7745c5c3_Var14 string = article.Date.Format("Mon, 02 Jan 2006")
-			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
+			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
@@ -223,8 +243,9 @@ 				_, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
 			}
 			return templ_7745c5c3_Err
 		})
-import "bytes"
+// Code generated by templ - DO NOT EDIT.
 // Code generated by templ - DO NOT EDIT.
+import "github.com/a-h/templ"
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}