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) }