Last active
November 9, 2018 01:08
-
-
Save etler/1270bfaee718c7dfd8c2401adaa18264 to your computer and use it in GitHub Desktop.
Automatically generated client-side TOC for github pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
(async () => { | |
const response = await fetch('https://api.github.com/repos/:user/:repo/contents/'); | |
const data = await response.json(); | |
let htmlString = '<ul>'; | |
for (let file of data) { | |
htmlString += `<li><a href="${file.path}">${file.name}</a></li>`; | |
} | |
htmlString += '</ul>'; | |
document.getElementsByTagName('body')[0].innerHTML = htmlString; | |
})() | |
</script> | |
<body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment