Add publication date to RSS feed
This commit is contained in:
parent
8a67093102
commit
0aa37fd12d
@ -215,7 +215,7 @@ public class MdBlog {
|
||||
.filter(e -> e.getKey().startsWith(blogPath) && (recursive || e.getKey().length() == path.length()))
|
||||
.forEach(e -> {
|
||||
Post p = e.getValue();
|
||||
feed.addItem(new RSSItem(p.getMetadata().title(), p.getMetadata().author(), config.link() + "/" + e.getKey().subPath(blogPath.length()), p.getMetadata().description()));
|
||||
feed.addItem(new RSSItem(p.getMetadata().date(), p.getMetadata().title(), p.getMetadata().author(), config.link() + "/" + e.getKey().subPath(blogPath.length()), p.getMetadata().description()));
|
||||
});
|
||||
ctx.respond(HttpStatusCodes.OK_200, new RSSResponse(feed));
|
||||
return;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package me.mrletsplay.mdblog.rss;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -55,6 +57,10 @@ public class RSSFeed {
|
||||
Element itemEl = doc.createElement("item");
|
||||
channel.appendChild(itemEl);
|
||||
|
||||
Element itDate = doc.createElement("pubDate");
|
||||
itDate.setTextContent(DateTimeFormatter.RFC_1123_DATE_TIME.format(item.date().atZone(ZoneId.systemDefault())));
|
||||
itemEl.appendChild(itDate);
|
||||
|
||||
Element itTitle = doc.createElement("title");
|
||||
itTitle.setTextContent(item.title());
|
||||
itemEl.appendChild(itTitle);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package me.mrletsplay.mdblog.rss;
|
||||
|
||||
public record RSSItem(String title, String author, String link, String description) {
|
||||
import java.time.Instant;
|
||||
|
||||
public record RSSItem(Instant date, String title, String author, String link, String description) {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user