diff --git a/layouts/partials/head.html b/layouts/partials/head.html index f217239d..41bc0b16 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -31,6 +31,7 @@ + {{ partial "analytics.html" . }} @@ -38,28 +39,5 @@ if (window.location.hostname == "phil-opp.github.io") { window.location.href = "http://os.phil-opp.com/"; } - - window.onload = function() { - var container = document.querySelector('#toc'); - - var selector = "h2"; - if (container.className.split(" ").indexOf("coarse") == -1) { - selector += ",h3"; - } - - var toc = initTOC({ - selector: selector, - scope: '.post', - overwrite: false, - prefix: 'toc' - }); - - var heading = document.createElement("H2"); - var heading_text = document.createTextNode("Table of Contents"); - heading.appendChild(heading_text); - - container.appendChild(heading); - container.appendChild(toc); - } diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 00000000..80c79a20 --- /dev/null +++ b/static/js/main.js @@ -0,0 +1,22 @@ +window.onload = function() { + var container = document.querySelector('#toc'); + + var selector = "h2"; + if (container.className.split(" ").indexOf("coarse") == -1) { + selector += ",h3"; + } + + var toc = initTOC({ + selector: selector, + scope: '.post', + overwrite: false, + prefix: 'toc' + }); + + var heading = document.createElement("H2"); + var heading_text = document.createTextNode("Table of Contents"); + heading.appendChild(heading_text); + + container.appendChild(heading); + container.appendChild(toc); +}