index — crispy-website @ a7d03e1162575c1b023c47fc794f81cf7bc00a4b

My personal homepage (very crispy)

rss: add
crispy-caesus crispy@crispy-caesus.eu
Thu, 02 Apr 2026 21:55:26 +0200
commit

a7d03e1162575c1b023c47fc794f81cf7bc00a4b

parent

0325680eb4676790a996d2f92c95826178f9aeb2

3 files changed, 64 insertions(+), 0 deletions(-)

jump to
M cmd/server/genblog.gocmd/server/genblog.go

@@ -25,6 +25,8 @@ fmt.Println("Generating blog page...")

blogDataSlice := generateBlogPage() fmt.Println("Generating blog posts...") generateBlogPosts(blogDataSlice) + fmt.Println("Generating rss...") + genRSS(blogDataSlice) } func genBlogDir() {
A cmd/server/genrss.go

@@ -0,0 +1,40 @@

+package main + +import ( + "fmt" + "os" + "text/template" +) + +type ( + rssItem struct { + Title string + Link string + } +) + +func genRSS(blogDataSlice []blogData) { + var rssItemSlice []rssItem + for _, post := range blogDataSlice { + rssItemSlice = append(rssItemSlice, rssItem{ + Title: post.Title, + Link: post.URL, + }) + } + + tpl, err := template.ParseFiles("templates/rss.xml.gotmpl") + if err != nil { + fmt.Printf("ERROR creating template: %s\n", err) + } + + f, err := os.Create("html/en/blog/rss.xml.html") + if err != nil { + fmt.Printf("ERROR creating xml: %s\n", err) + panic(1) + } + + err = tpl.ExecuteTemplate(f, "rss.xml.gotmpl", rssItemSlice) + if err != nil { + fmt.Printf("ERROR executing template: %s\n", err) + } +}
A templates/rss.xml.gotmpl

@@ -0,0 +1,22 @@

+<?xml version="1.0" encoding="UTF-8"?> +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> +<channel> + <title>crispy blog</title> + <link>https://crispy-caesus.eu/blog</link> + <description> + Just my little blog with thoughts and cursed solutions to stupid problems + </description> + <language>en-us</language> + <atom:link + href="https://crispy-caesus.eu/blog/rss_en.xml" + rel="self" + type="application/rss+xml" + /> + + {{range .}}<item> + <title>{{.Title}}</title> + <link>https://crispy-caesus.eu/{{.Link}}</link> + </item> + {{end}} +</channel> +</rss>