-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathfeed.page.ts
More file actions
34 lines (30 loc) · 1015 Bytes
/
feed.page.ts
File metadata and controls
34 lines (30 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export const url = "/feed";
export default function ({ search }: { search: any }) {
// Generate RSS content for /feed to match original tinyclouds.org
const posts = search.pages()
.filter((page: any) => page.title && page.publish_date)
.sort((a: any, b: any) =>
new Date(b.publish_date).getTime() - new Date(a.publish_date).getTime()
);
const rssItems = posts.map((post: any) => {
const url = `https://tinyclouds.org${post.url}`;
const date = new Date(post.publish_date).toUTCString();
return ` <item>
<title>${post.title}</title>
<link>${url}</link>
<guid>${url}</guid>
<pubDate>${date}</pubDate>
</item>`;
}).join("\n");
return `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Ryan Dahl</title>
<description>Personal blog of Ryan Dahl</description>
<link>https://tinyclouds.ry.deno.net</link>
<language>en</language>
<generator>Lume v3.0.5</generator>
${rssItems}
</channel>
</rss>`;
}