File tree 1 file changed +15
-4
lines changed
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ interface MermaidPluginOptions extends MermaidConfig {
11
11
12
12
// Additional configuration for plugin itself. Separate model, not to risk name conflicts with future MermaidConfig options
13
13
export interface MermaidPluginConfig {
14
- class ?: string ;
14
+ class ?: string ;
15
15
}
16
16
17
17
const DEFAULT_OPTIONS : MermaidConfig = {
@@ -42,10 +42,21 @@ export function MermaidPlugin(
42
42
src =
43
43
"\nimport Mermaid from 'vitepress-plugin-mermaid/Mermaid.vue';\n" +
44
44
src ;
45
- src = src . replace (
46
- "// install global components" ,
47
- "// install global components\n\t\tapp.component('Mermaid', Mermaid);\n"
45
+
46
+ const lines = src . split ( "\n" ) ;
47
+
48
+ const targetLineIndex = lines . findIndex ( ( line ) =>
49
+ line . includes ( "app.component" )
50
+ ) ;
51
+
52
+ lines . splice (
53
+ targetLineIndex ,
54
+ 0 ,
55
+ ' app.component("Mermaid", Mermaid);'
48
56
) ;
57
+
58
+ src = lines . join ( "\n" ) ;
59
+
49
60
return {
50
61
code : src ,
51
62
map : null , // provide source map if available
You can’t perform that action at this time.
0 commit comments