package atom import ( "encoding/xml" "fmt" "net/url" "path/filepath" "time" "tangled.sh/icyphox.sh/vite/config" "tangled.sh/icyphox.sh/vite/types" ) type AtomLink struct { XMLName xml.Name `xml:"link"` Href string `xml:"href,attr"` Rel string `xml:"rel,attr,omitempty"` } type AtomSummary struct { XMLName xml.Name `xml:"summary"` Content string `xml:",chardata"` Type string `xml:"type,attr"` } type AtomAuthor struct { XMLName xml.Name `xml:"author"` Name string `xml:"name"` Email string `xml:"email"` } type AtomEntry struct { XMLName xml.Name `xml:"entry"` Title string `xml:"title"` Updated string `xml:"updated"` ID string `xml:"id"` Link *AtomLink Summary *AtomSummary } type AtomFeed struct { XMLName xml.Name `xml:"feed"` Xmlns string `xml:"xmlns,attr"` Title string `xml:"title"` Subtitle string `xml:"subtitle"` ID string `xml:"id"` Updated string `xml:"updated"` Link *AtomLink Author *AtomAuthor `xml:"author"` Entries []AtomEntry } // Creates a new Atom feed. func NewAtomFeed(srcDir string, posts []types.Post) ([]byte, error) { entries := []AtomEntry{} for _, p := range posts { dateStr := p.Meta["date"].(string) date, err := time.Parse("2006-01-02", dateStr) if err != nil { return nil, err } rfc3339 := date.Format(time.RFC3339) var summaryContent string if subtitle, ok := p.Meta["subtitle"]; ok { summaryContent = fmt.Sprintf("