<rss version="2.0">
<channel>
<title>note</title>
<link>https://halo.xxx.cn:9443/</link>
<description>note</description>
<item>
<title>
<![CDATA[ Hello Halo ]]>
</title>
<link>https://halo.xxx.cn:9443/https://halo.xxx.cn:9443/archives/hello-halo</link>
<description>
<![CDATA[ 如果你看到了这一篇文章,那么证明你已经安装成功了,感谢使用 Halo 进行创作,希望能够使用愉快。 ]]>
</description>
<guid>/archives/hello-halo</guid>
<pubDate>Sat, 7 Oct 2023 03:19:04 GMT</pubDate>
</item>
</channel>
</rss>
private Mono<ServerResponse> postListResultToXmlServerResponse(
Mono<ListResult<Post>> postListResult,
FeedContext feedContext, RSS2 rss2) {
return postListResult
.flatMapIterable(ListResult::getItems)
.flatMap(post -> {
// Create item
var permalink = post.getStatusOrDefault().getPermalink();
if (permalink != null) {
var permalinkUri = URI.create(permalink);
if (!permalinkUri.isAbsolute()) {
try {
// 此处将相对路径转为了绝对路径
permalinkUri = feedContext.externalUrl.toURI().resolve(permalinkUri);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
permalink = permalinkUri.toString();
}
var itemBuilder = RSS2.Item.builder()
.title(post.getSpec().getTitle())
// 此处再次拼接了服务器externalUrl
.link(feedContext.externalUrl.toString() + permalink)
.pubDate(post.getSpec().getPublishTime())
.guid(post.getStatusOrDefault().getPermalink());
// TODO lastBuildDate need upgrade halo dependency version
// Set description
}