Skip to content

Commit 455dedd

Browse files
committed
feat: add basic readme page which pulls raw readme from github and then renders it in html, cba to make it more cleaner
1 parent 3bc8359 commit 455dedd

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

example/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ <h1>faucet</h1>
1919
</a>
2020
|
2121
<a href="https://faucet.bnajns.hackclub.app">Hosted Demo</a>
22+
|
23+
<a href="/readme.html">HTML Readme</a>
2224
</li>
2325
</ul>
2426
</hero>

example/readme.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>faucet - readme</title>
7+
<link rel="stylesheet" href="/style.css" />
8+
<style>
9+
section img {
10+
max-width: 50%;
11+
height: auto;
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
<hero>
17+
<h1>faucet - readme</h1>
18+
<p>HTML version of the README.md file, rendering may not be perfect.</p>
19+
<ul>
20+
<a href="/">Go back to home</a>
21+
|
22+
<a href="https://github.com/BananaJeanss/faucet/blob/main/README.md"
23+
>GitHub README.md</a
24+
>
25+
</ul>
26+
</hero>
27+
<hr />
28+
<section></section>
29+
</body>
30+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
31+
<script>
32+
async function loadReadme() {
33+
const section = document.querySelector("section");
34+
try {
35+
const res = await fetch(
36+
"https://raw.githubusercontent.com/BananaJeanss/faucet/refs/heads/main/README.md"
37+
);
38+
if (!res.ok) throw new Error("Failed to fetch README.md");
39+
40+
const markdown = await res.text();
41+
section.innerHTML = marked.parse(markdown);
42+
} catch (err) {
43+
section.innerHTML = `<p style="color:red;">Error loading README.md: ${err.message}</p>`;
44+
}
45+
}
46+
47+
loadReadme();
48+
</script>
49+
</html>

0 commit comments

Comments
 (0)