-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.html
112 lines (90 loc) · 3.11 KB
/
doc.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Python</title>
<script>
function GenerateIndex(repoPath,header,elementId)
{
(async () => {
debugger;
const response = await fetch(`https://api.github.com/repos/${repoPath}/git/trees/main?recursive=1`);
const data = await response.json();
let htmlString = `<h2 id="h2" class="header2">${header}</h2>`;
for (let file of data.tree) {
if (file.path.toLowerCase().endsWith('.md') == true) {
var actualpath = baseUrl + file.path;
var fileName = (file.path).replace("/index.md", "");
fileName = (fileName).replace(".md", "");
var displayName = fileName.split('/');
displayName = displayName[displayName.length - 1];
var randomColor = "#" +Math.floor(Math.random()*16777215).toString(16);
htmlString += `<a class="link" href="${fileName}" onclick="location.href='${fileName}'">📄 ${fileName}</a>`;
}
}
htmlString += '';
var result = "<div class='bookshelf'>";
result += htmlString;
result += '</div>';
document.getElementById(elementId).innerHTML = result;
})();
}
</script>
<style>
body {
font-family: Consolas;
background-color: rgb(248, 248, 248);
color: rgb(44, 44, 44);
}
.link, .header1 {
background-color: transparent;
color: rgb(65, 65, 65);
margin: 5px;
border: 1px solid rgba(255, 255, 255, 0);
text-shadow: 2px 2px 8px rgb(255, 255, 255);
align-items: center;
font-style:normal;
font-size: 25px;
display:flex
}
.link:hover{
color: rgba(40, 40, 40, 0.944);
font-weight: bolder;
text-shadow: 1px 1px 18px rgb(0, 213, 255);
border-radius: 1px 1px;
font-size: 25px;
background-color: aqua;
}
.header1{
font-size: 35px;
}
.header2{
font-size: 30px;
background-color:rgb(45, 45, 45);
padding: 10px;
color: aliceblue;
}
.figcaption { font-size: 20px;}
.icon { font-size: 20px; }
.bookshelf { background-color: rgba(255, 255, 255, 0); }
img { width: 100px; height: 100px; }
a:link { text-decoration: none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:active { text-decoration: none; }
</style>
</head>
<body>
<h1 id="h1" class="header1">📚</h1>
<div id="h2content">Loading...</div>
<script>
debugger;
var repoPath = "killercodes/py";
var baseUrl = window.location.href;
document.querySelector("#h1").innerHTML += repoPath;
GenerateIndex(repoPath,"Python 3","h2content");
</script>
</body>
</html>