|
| 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>My Slide Decks</title> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + font-family: system-ui, sans-serif; |
| 10 | + max-width: 800px; |
| 11 | + margin: 2rem auto; |
| 12 | + padding: 0 1rem; |
| 13 | + line-height: 1.6; |
| 14 | + } |
| 15 | + h1 { font-size: 2rem; } |
| 16 | + ul { list-style: none; padding: 0; } |
| 17 | + li { margin: 0.5rem 0; } |
| 18 | + a { |
| 19 | + text-decoration: none; |
| 20 | + color: #0366d6; |
| 21 | + font-size: 1.2rem; |
| 22 | + } |
| 23 | + a:hover { text-decoration: underline; } |
| 24 | + .loading { color: #666; } |
| 25 | + </style> |
| 26 | +</head> |
| 27 | +<body> |
| 28 | + <h1>📚 My Slide Decks</h1> |
| 29 | + <p class="loading">Loading decks…</p> |
| 30 | + <ul id="deck-list"></ul> |
| 31 | + |
| 32 | + <script> |
| 33 | + const user = "EduBricksHub"; |
| 34 | + const repo = "slide-decks"; |
| 35 | + const branch = "main"; // change if using a different branch |
| 36 | + |
| 37 | + const distUrl = `https://api.github.com/repos/${user}/${repo}/contents/dist?ref=${branch}`; |
| 38 | + |
| 39 | + async function loadDecks() { |
| 40 | + try { |
| 41 | + const response = await fetch(distUrl); |
| 42 | + const items = await response.json(); |
| 43 | + |
| 44 | + const list = document.getElementById("deck-list"); |
| 45 | + const loading = document.querySelector(".loading"); |
| 46 | + |
| 47 | + loading.remove(); |
| 48 | + |
| 49 | + items |
| 50 | + .filter(item => item.type === "dir") // only directories |
| 51 | + .forEach(folder => { |
| 52 | + const li = document.createElement("li"); |
| 53 | + const a = document.createElement("a"); |
| 54 | + a.href = `./${folder.name}/`; |
| 55 | + a.textContent = folder.name; |
| 56 | + li.appendChild(a); |
| 57 | + list.appendChild(li); |
| 58 | + }); |
| 59 | + } catch (err) { |
| 60 | + document.querySelector(".loading").textContent = |
| 61 | + "Failed to load deck list."; |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + loadDecks(); |
| 66 | + </script> |
| 67 | +</body> |
| 68 | +</html> |
0 commit comments