Avatar

joshmock

4 public vals
Joined February 10, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { dataToRSS } from "https://esm.town/v/joshmock/dataToRSS";
import { githubStars } from "https://esm.town/v/joshmock/githubStars";
export async function githubStarsRSS(username) {
let data = await githubStars(username);
return await dataToRSS(data, {
title: `Starred Github Repos - ${username}`,
link: `https://github.com/${username}?tab=stars`,
description: "Starred Github repos",
keys: {
title: "full_name",
description: "description",
link: "html_url",
pubDate: "created_at",
},
});
}
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
export async function dataToRSS(data, settings) {
let { title, link, description } = settings;
let rss = [
`<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>${title}</title>
<description>${description}</description>
<link>${link}</link>`,
];
data.forEach((item) =>
rss.push(`<item>
<title>${item[settings.keys.title]}</title>
<description>${item[settings.keys.description]}</description>
<link>${item[settings.keys.link]}</link>
<guid isPermaLink="true">${item[settings.keys.link]}</guid>
<pubDate>${item[settings.keys.pubDate]}</pubDate>
</item>`)
);
rss.push(`</channel></rss>`);
return rss.join("");
}
1
2
3
4
5
6
import { fetch } from "https://esm.town/v/std/fetch";
export async function githubStars(username) {
let res = await fetch(`https://api.github.com/users/${username}/starred`);
return await res.json();
}
1
2
3
4
5
6
7
8
9
10
import { set } from "https://esm.town/v/std/set?v=11";
let { tw } = await import("https://esm.town/v/joshmock/tw");
export async function untitledTW(params) {
if (params && params.val) {
tw = params.val;
await set("tw", tw);
}
return tw;
}
Next