aboutsummaryrefslogtreecommitdiff
path: root/loaders
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-28 21:33:44 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-28 21:33:44 -0500
commitf0c03a9b8e15387c4defd0a0e3e0298324406fae (patch)
tree564011d0265666953b17258954ff68614ff6566a /loaders
parent2f0439621cff059e414d67f6ce43a7a6c4de13bc (diff)
downloadhomepage-f0c03a9b8e15387c4defd0a0e3e0298324406fae.tar.xz
homepage-f0c03a9b8e15387c4defd0a0e3e0298324406fae.zip
Add wg2nd
Diffstat (limited to 'loaders')
-rw-r--r--loaders/marked.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/loaders/marked.js b/loaders/marked.js
new file mode 100644
index 0000000..f3c8fcb
--- /dev/null
+++ b/loaders/marked.js
@@ -0,0 +1,16 @@
+const { Marked } = require('marked');
+const { markedHighlight } = require('marked-highlight');
+const hljs = require('highlight.js');
+
+module.exports = function loader(source) {
+ const marker = new Marked(
+ markedHighlight({
+ highlight(code, lang) {
+ const language = hljs.getLanguage(lang) ? lang : 'plaintext';
+ return hljs.highlight(code, { language }).value;
+ }
+ })
+ );
+
+ return marker.parse(source);
+}