Compare commits

..

No commits in common. "1fa7da9ebb059ccf86734878ec1408d561ba9058" and "1aebc2c100ae8e53098a873146a2a74a683f64ae" have entirely different histories.

4 changed files with 9 additions and 13 deletions

View file

@ -19,6 +19,11 @@ module.exports = [
source: "/js/main.js",
target: "/static/bundle.js"
},
{
type: "module",
source: "/js/hljs.js",
target: "/static/hljs.js"
},
{
type: "file",
source: "/assets/fonts/whitney-500.woff",

View file

@ -40,6 +40,7 @@ html
!= JSON.stringify([...static.keys()].map(k => [k, getStatic(k)]))
| )
link(rel="stylesheet" type="text/css" href=getStatic("/sass/main.sass"))
link(rel="preload" as="script" href=getStatic("/js/hljs.js"))
script(type="module" src=getStatic("/js/main.js"))
body
main.main

View file

@ -12,19 +12,7 @@ class HighlightedCode extends ElemJS {
this.element.appendChild(child)
}
}
if (this.element.textContent.length > 80) {
/*
no need to highlight very short code blocks:
- content inside might not be code, some users still use code blocks
for plaintext quotes
- language detection will almost certainly be incorrect
- even if it's code and the language is detected, the user will
be able to mentally format small amounts of code themselves
feel free to change the threshold number
*/
lazyLoad("https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10/build/highlight.min.js").then(hljs => hljs.highlightBlock(this.element))
}
lazyLoad("./static/hljs.js").then(hljs => hljs.highlightBlock(this.element))
}
}

2
src/js/hljs.js Normal file
View file

@ -0,0 +1,2 @@
const hljs = require("highlight.js")
module.exports = hljs