-
Notifications
You must be signed in to change notification settings - Fork 2
/
ec.config.mjs
43 lines (38 loc) · 1.06 KB
/
ec.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { pluginCollapsibleSections } from "@expressive-code/plugin-collapsible-sections";
import { pluginLineNumbers } from "@expressive-code/plugin-line-numbers";
import { defineEcConfig } from "astro-expressive-code";
function lineNumbers() {
// Only show line numbers on these languages
const lineNumberLanguages = [
"js",
"jsx",
"ts",
"tsx",
"ini",
];
let plugin = pluginLineNumbers();
return {
...plugin,
name: `Line numbers (${lineNumberLanguages.join(", ")})`,
hooks: {
preprocessMetadata: (opt) => {
const { codeBlock: { language } } = opt;
if (lineNumberLanguages.includes(language)) {
return plugin.hooks.preprocessMetadata(opt);
}
},
postprocessRenderedBlock: (opt) => {
const { codeBlock: { language } } = opt;
if (lineNumberLanguages.includes(language)) {
return plugin.hooks.postprocessRenderedBlock(opt);
}
},
}
};
}
export default defineEcConfig({
plugins: [
lineNumbers(),
pluginCollapsibleSections(),
],
});