Skip to content

Commit 0a38c63

Browse files
authored
Update default.html
add directory listing
1 parent 49c6170 commit 0a38c63

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

_layouts/default.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repo
2121
{% endif %}
2222

2323
<p>{{ site.description | default: site.github.project_tagline }}</p>
24+
25+
<script>
26+
(async () => {
27+
const response = await fetch('https://api.github.com/repos/:user/:repo/contents/');
28+
const data = await response.json();
29+
let htmlString = '<ul>';
30+
for (let file of data) {
31+
htmlString += `<li><a href="${file.path}">${file.name}</a></li>`;
32+
}
33+
htmlString += '</ul>';
34+
document.getElementsByTagName('body')[0].innerHTML = htmlString;
35+
})()
36+
</script>
2437

2538
{% if site.github.is_project_page %}
2639
<p class="view"><a href="{{ site.github.repository_url }}">View the Project on GitHub <small>{{ site.github.repository_nwo }}</small></a></p>

0 commit comments

Comments
 (0)