Skip to content

Instantly share code, notes, and snippets.

@etler
Last active November 9, 2018 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etler/1270bfaee718c7dfd8c2401adaa18264 to your computer and use it in GitHub Desktop.
Save etler/1270bfaee718c7dfd8c2401adaa18264 to your computer and use it in GitHub Desktop.
Automatically generated client-side TOC for github pages
<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