aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/http/feed.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/cmd/http/feed.go b/cmd/http/feed.go
new file mode 100644
index 0000000..41ec399
--- /dev/null
+++ b/cmd/http/feed.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+ "time"
+)
+
+/*
+ post.File = file
+ post.Title = title
+ post.Date = date
+ post.Tags = tags
+*/
+
+// use this to check for valid feed: https://validator.w3.org/feed/
+func generateFeed(domain string, p *Posts) []byte {
+ feed := `<?xml version="1.0" encoding="UTF-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>ScerbaDotOrg</title>
+ <subtitle>Blog feed</subtitle>
+ <link rel="self" href="https://` + domain + `/atom.xml"/>
+ <link href="https://` + domain + `"/>
+ <author>
+ <name>Alex Scerba</name>
+ </author>
+ <id>https://` + domain + `</id>
+ <updated>` + time.Now().UTC().Format("2006-01-02T15:04:05.000Z") + `</updated>`
+
+ for _, post := range p.Collection {
+ entry := `
+ <entry>
+ <title>` + post.Title + `</title>
+ <link href="https://` + domain + `/posts/` + post.File + `.html"/>
+ <id>https://` + domain + `/posts/` + post.File + `</id>
+ <published>` + post.Date + `T00:00:00.000Z</published>`
+ entry = entry + `
+ </entry>`
+ feed = feed + entry
+ }
+ feed = feed + `
+</feed>`
+
+ return []byte(feed)
+}