1
0
dwelling-home/web/rss.templ

38 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

package web
import "net/http"
import "strings"
import "time"
import "git.arav.su/Arav/dwelling-home/pkg/mindflow"
import "git.arav.su/Arav/dwelling-home/pkg/util"
templ RSS(host, author string, posts []mindflow.Post, r *http.Request) {
@templ.Raw("<?xml version=\"1.0\" encoding=\"utf-8\" ?>")
<rss version="2.0">
<channel>
<title>Arav's dwelling</title>
<description>What's going on with me and my machines.</description>
<language>en-gb</language>
2024-09-15 15:29:42 +04:00
<link>{ host }@templ.Raw("</link>")
for _, post := range posts {
<item>
<title>{ post.Title }</title>
<category>{ post.Category.Name }</category>
<guid>{ post.PostID() }</guid>
<pubDate>{ util.ToClientTimezone(post.Date, r).Format(time.RFC1123Z) }</pubDate>
2024-09-15 15:29:42 +04:00
<link>{ post.PostURL(r.Host, true) }@templ.Raw("</link>")
<author>{ author }</author>
<description>
@templ.Raw("<![CDATA[")
for _, line := range strings.Split(post.Body, "\n") {
<p>{ line }</p>
}
@templ.Raw("]]>")
</description>
</item>
}
</channel>
</rss>
}