-
Notifications
You must be signed in to change notification settings - Fork 0
/
pages.html
70 lines (65 loc) · 2.35 KB
/
pages.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
---
layout: page
head-extra: noindex.html
nav-short: true
show-avatar: false
---
<html>
<body>
<div>
<h2>MarkDown Pages</h2>
<ul id="md_list">
</ul>
<h2>HTML Pages</h2>
<ul id="html_list">
</ul>
</div>
<script>
const filterFiles1 = (filter) => {
filter = filter.toLowerCase()
return (file) => {
const filePath = file.path;
const fileName = file.path.replace('.md', '').toLowerCase().replace(/-/g, ' ');
const isMD = (/.md$/).test(filePath);
const isNotREADME = filePath !== 'README.md';
return isMD && isNotREADME;
}
}
const renderList1 = (data, filter = '') => {
let htmlString = '<ul>';
for (let file of data.filter(filterFiles1(filter))) {
const filePath = file.path.replace('.md', '');
const fileName = file.path.replace('.md', '').toLowerCase().replace(/-/g, ' ');
htmlString += `<li><a href="https://bradleykennedy.co.uk/${filePath}" target="_blank" rel="noopener noreferrer">${fileName}</a></li>`;
}
htmlString += '</ul>';
document.getElementById('md_list').innerHTML = htmlString;
}
const filterFiles2 = (filter) => {
filter = filter.toLowerCase()
return (file) => {
const filePath = file.path;
const fileName = file.path.replace('.html', '').toLowerCase().replace(/-/g, ' ');
const isHTML = (/.html$/).test(filePath);
return isHTML;
}
}
const renderList2 = (data, filter = '') => {
let htmlString = '<ul>';
for (let file of data.filter(filterFiles2(filter))) {
const filePath = file.path.replace('.html', '');
const fileName = file.path.replace('.html', '').toLowerCase().replace(/-/g, ' ');
htmlString += `<li><a href="https://bradleykennedy.co.uk/${filePath}" target="_blank" rel="noopener noreferrer">${fileName}</a></li>`;
}
htmlString += '</ul>';
document.getElementById('html_list').innerHTML = htmlString;
}
(async () => {
const response = await fetch('https://api.github.com/repos/b-kennedy0/b-kennedy0.github.io/contents/');
const data = await response.json();
renderList1(data);
renderList2(data);
})()
</script>
<body>
</html>