-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (54 loc) · 1.73 KB
/
index.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const links = [
{
text: "also check out luna clippa!",
href: "https://lunaclippa.bandcamp.com/album/shall-we",
},
{ text: "also check out nlo!", href: "https://nlolnlolnlo.neocities.org" },
{
text: "also check out disa!",
href: "https://somepeoplecallmedisa.github.io/",
},
{
text: "also check out webbop!",
href: "https://www.dempah.com/bigsearch/",
},
{
text: "also check out sillycore kittycore!!",
href: "https://discord.gg/kittycore-sillycore-1025339762493624350",
},
];
const el = document.getElementById("header-check-out");
const link = links[Math.floor(Math.random() * links.length)];
el.textContent = link.text;
el.setAttribute("href", link.href);
function create_article(title, flavour_text) {
const elem = document.createElement("div");
elem.className = "article";
const new_title = document.createElement("h1");
new_title.textContent = title;
const new_text = document.createElement("div");
new_text.textContent = flavour_text;
const new_link = document.createElement("a");
new_link.href = title;
new_link.textContent = "read";
elem.appendChild(new_title);
elem.appendChild(new_text);
elem.appendChild(new_link);
document.getElementById("articles").appendChild(elem);
}
fetch(
"https://raw.githubusercontent.com/eliseydudin/github-articles/refs/heads/main/articles-map.json"
)
.then((resp) => resp.text())
.then((text) => {
console.log(text);
const obj = JSON.parse(text);
if (Object.keys(obj).length === 0) {
return;
}
const articles = obj.articles.reverse();
for (let article of articles) {
create_article(article.title, article.flavour_text);
}
})
.catch((error) => console.error("Error fetching articles:", error));