Only import necessary highlight.js files

This commit is contained in:
Misode
2022-05-06 16:25:06 +02:00
parent ea7e8802c4
commit 690e2f60bf
5 changed files with 275 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
import hljs from 'highlight.js'
import hljs from 'highlight.js/lib/core'
import json from 'highlight.js/lib/languages/json'
import { marked } from 'marked'
import { route } from 'preact-router'
import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'
@@ -11,6 +12,8 @@ import { parseFrontMatter, versionContent } from '../Utils'
const HASH = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M6.368 1.01a.75.75 0 01.623.859L6.57 4.5h3.98l.46-2.868a.75.75 0 011.48.237L12.07 4.5h2.18a.75.75 0 010 1.5h-2.42l-.64 4h2.56a.75.75 0 010 1.5h-2.8l-.46 2.869a.75.75 0 01-1.48-.237l.42-2.632H5.45l-.46 2.869a.75.75 0 01-1.48-.237l.42-2.632H1.75a.75.75 0 010-1.5h2.42l.64-4H2.25a.75.75 0 010-1.5h2.8l.46-2.868a.75.75 0 01.858-.622zM9.67 10l.64-4H6.33l-.64 4h3.98z"></path></svg>'
hljs.registerLanguage('json', json)
marked.use({
highlight: (code, lang) => {
if (lang === '') return undefined