Compare commits
No commits in common. "1fa7da9ebb059ccf86734878ec1408d561ba9058" and "1aebc2c100ae8e53098a873146a2a74a683f64ae" have entirely different histories.
1fa7da9ebb
...
1aebc2c100
4 changed files with 9 additions and 13 deletions
5
spec.js
5
spec.js
|
@ -19,6 +19,11 @@ module.exports = [
|
||||||
source: "/js/main.js",
|
source: "/js/main.js",
|
||||||
target: "/static/bundle.js"
|
target: "/static/bundle.js"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "module",
|
||||||
|
source: "/js/hljs.js",
|
||||||
|
target: "/static/hljs.js"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "file",
|
type: "file",
|
||||||
source: "/assets/fonts/whitney-500.woff",
|
source: "/assets/fonts/whitney-500.woff",
|
||||||
|
|
|
@ -40,6 +40,7 @@ html
|
||||||
!= JSON.stringify([...static.keys()].map(k => [k, getStatic(k)]))
|
!= JSON.stringify([...static.keys()].map(k => [k, getStatic(k)]))
|
||||||
| )
|
| )
|
||||||
link(rel="stylesheet" type="text/css" href=getStatic("/sass/main.sass"))
|
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"))
|
script(type="module" src=getStatic("/js/main.js"))
|
||||||
body
|
body
|
||||||
main.main
|
main.main
|
||||||
|
|
|
@ -12,19 +12,7 @@ class HighlightedCode extends ElemJS {
|
||||||
this.element.appendChild(child)
|
this.element.appendChild(child)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.element.textContent.length > 80) {
|
lazyLoad("./static/hljs.js").then(hljs => hljs.highlightBlock(this.element))
|
||||||
/*
|
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
src/js/hljs.js
Normal file
2
src/js/hljs.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
const hljs = require("highlight.js")
|
||||||
|
module.exports = hljs
|
Loading…
Add table
Add a link
Reference in a new issue