From fbafe4f6716b308d9bfa7c63bf8228d473bf17c8 Mon Sep 17 00:00:00 2001 From: Aaron Qian Date: Fri, 11 Nov 2022 14:33:38 -0800 Subject: [PATCH] migrate syntax highlight to js bundle --- assets/scripts/features/index.js | 4 ++++ assets/scripts/features/syntaxhighlight/hljs.js | 3 +++ assets/scripts/features/syntaxhighlight/index.js | 3 +++ layouts/_default/single.html | 5 ----- layouts/notes/list.html | 4 ---- layouts/notes/single.html | 4 ---- 6 files changed, 10 insertions(+), 13 deletions(-) create mode 100644 assets/scripts/features/syntaxhighlight/hljs.js create mode 100644 assets/scripts/features/syntaxhighlight/index.js diff --git a/assets/scripts/features/index.js b/assets/scripts/features/index.js index 80565c9..1657c5f 100644 --- a/assets/scripts/features/index.js +++ b/assets/scripts/features/index.js @@ -13,3 +13,7 @@ if (process.env.FEATURE_DARKMODE) { if (process.env.FEATURE_FLOWCHART) { import('./flowchart'); } + +if (process.env.FEATURE_SYNTAXHIGHLIGHT) { + import('./syntaxhighlight'); +} diff --git a/assets/scripts/features/syntaxhighlight/hljs.js b/assets/scripts/features/syntaxhighlight/hljs.js new file mode 100644 index 0000000..59516cf --- /dev/null +++ b/assets/scripts/features/syntaxhighlight/hljs.js @@ -0,0 +1,3 @@ +import hljs from 'highlight.js'; + +hljs.highlightAll(); diff --git a/assets/scripts/features/syntaxhighlight/index.js b/assets/scripts/features/syntaxhighlight/index.js new file mode 100644 index 0000000..689e67a --- /dev/null +++ b/assets/scripts/features/syntaxhighlight/index.js @@ -0,0 +1,3 @@ +if (process.env.FEATURE_SYNTAXHIGHLIGHT_HLJS) { + import('./hljs'); +} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index d782105..976b1ac 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -192,11 +192,6 @@ {{ end }} {{ define "scripts" }} - - - {{ if .Params.math }} {{ partial "math.html" . }} diff --git a/layouts/notes/list.html b/layouts/notes/list.html index b2d9897..d60d239 100644 --- a/layouts/notes/list.html +++ b/layouts/notes/list.html @@ -57,10 +57,6 @@ {{ end }} {{ define "scripts" }} - - {{ if .Params.math }} {{ partial "math.html" . }} {{ end }} diff --git a/layouts/notes/single.html b/layouts/notes/single.html index 60544a1..7f8ebec 100644 --- a/layouts/notes/single.html +++ b/layouts/notes/single.html @@ -47,10 +47,6 @@ {{ end }} {{ define "scripts" }} - - {{ if .Params.math }} {{ partial "math.html" . }} {{ end }}