blob: 59f5ad10d7845e7cb3eb5cb14baffa4c949fbf53 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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, posts []*Post) []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 posts {
entry := `
<entry>
<title>` + post.Title + `</title>
<link href="https://` + domain + `/blog/` + post.File + `"/>
<id>https://` + domain + `/blog/` + post.File + `</id>
<published>` + post.Date + `T00:00:00.000Z</published>
<updated>` + post.Date + `T00:00:00.000Z</updated>
<summary>Blog post</summary>`
entry = entry + `
</entry>`
feed = feed + entry
}
feed = feed + `
</feed>`
return []byte(feed)
}
|