-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeed.tmpl.js
More file actions
28 lines (25 loc) · 752 Bytes
/
Copy pathfeed.tmpl.js
File metadata and controls
28 lines (25 loc) · 752 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
export const url = "/feed.json";
export default function ({ site, search }, { md, url, date, htmlUrl }) {
const feed = {
version: "https://jsonfeed.org/version/1",
title: site.title,
home_page_url: url("", true),
feed_url: url("feed.json", true),
description: site.description,
author: {
name: site.author.name,
url: site.author.url,
},
items: [],
};
for (const post of search.pages("type=posts").reverse()) {
feed.items.push({
id: url(post.data.url, true),
url: url(post.data.url, true),
title: post.data.title,
content_html: htmlUrl(md(post.data.content), true),
date_published: date(post.data.date, "ATOM"),
});
}
return JSON.stringify(feed, null, 2);
}