notebook_feed = async function (source) {
var observable_favicon = "https://static.observablehq.com/favicon-512.0667824687f99c942a02e06e2db1a060911da0bf3606671676a255b1cf97b4fe.png";
if (source === 'recent') {
source = 'public';
var notebooks = await fetch_notebooks(source);
return ({
version: "https://jsonfeed.org/version/1",
title: "Recent Notebooks / Observable",
description: "The firehose of all published notebooks at https://observablehq.com/",
home_page_url: "https://observablehq.com/recent",
feed_url: "https://endpointservice.web.app/notebooks/@jrus/feed/deployments/feeds/recent",
favicon: observable_favicon,
icon: observable_favicon,
items: notebooks.map(feed_item)
});
} else if (source[0] == '@') {
var login = source.slice(1);
var notebooks = await fetch_notebooks(source);
var authors = Object.fromEntries([
...notebooks.map((n) => [n.creator.login, n.creator]),
...notebooks.map((n) => [n.owner.login, n.owner]),
])
if (login in authors) {
var author = authors[login];
return ({
version: "https://jsonfeed.org/version/1",
title: `${author.name || login} / Observable`,
description: `${author.bio}`,
home_page_url: `http://observablehq.com/@${login}`,
feed_url: `https://endpointservice.web.app/notebooks/@jrus/feed/deployments/feeds/@${login}`,
favicon: author.avatar_url,
icon: author.avatar_url,
items: notebooks.map(feed_item)
});
} else {
return ({
version: "https://jsonfeed.org/version/1",
title: `${login} / Observable`,
home_page_url: `http://observablehq.com/@${login}`,
feed_url: `https://endpointservice.web.app/notebooks/@jrus/feed/deployments/feeds/@${login}`,
favicon: observable_favicon,
icon: observable_favicon,
items: notebooks.map(feed_item)
});
}
}
}