Skip to content

Commit 428c761

Browse files
authored
fix(docs): only import necessary hljs languages (#155)
1 parent 95683f3 commit 428c761

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

docs/components/MarkdownContent/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import styles from "./index.scss?inline";
99

1010
import { marked } from "marked";
1111
import { markedHighlight } from "marked-highlight";
12-
import hljs from "highlight.js";
12+
import hljs from "@/utilities/hljs";
1313

1414
import { ContentBase } from "@/components/ContentBase";
1515

docs/components/SourceCode/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import styles from "./index.scss?inline";
99

10-
import hljs from "highlight.js";
10+
import hljs from "@/utilities/hljs";
1111

1212
export class CdsEsDocsSourceCode extends HTMLElement {
1313
#observer = new MutationObserver(() => this.#render());

docs/utilities/hljs.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright IBM Corp. 2026
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import hljs from "highlight.js/lib/core";
9+
10+
import xml from "highlight.js/lib/languages/xml";
11+
import scss from "highlight.js/lib/languages/scss";
12+
import shell from "highlight.js/lib/languages/shell";
13+
14+
hljs.registerLanguage("html", xml);
15+
hljs.registerLanguage("scss", scss);
16+
hljs.registerLanguage("console", shell);
17+
18+
export default hljs;

0 commit comments

Comments
 (0)