diff options
Diffstat (limited to 'assets')
-rw-r--r-- | assets/js/main.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/assets/js/main.js b/assets/js/main.js index 231191b..0a11d07 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -55,3 +55,17 @@ function smoothScrollTo(y, time) { })(); } } + +// Init highlight js +document.addEventListener('DOMContentLoaded', function(event) { + document.querySelectorAll('pre code').forEach((block) => { + hljs.highlightBlock(block); + var lang = block.getAttribute('data-lang'); + if (!lang) { + lang = block + .getAttribute('class') + .replace('hljs ', ''); + } + block.parentNode.setAttribute('data-lang', lang); + }); +}); |