File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { fileURLToPath } from 'node:url' ;
2
2
import type { AstroConfig , AstroIntegration } from 'astro' ;
3
+ import type { ExpressiveCodePlugin } from 'astro-expressive-code' ;
3
4
import { extraIntegrations } from './integrations.js' ;
4
5
import { updateMarkdownConfig } from './remark/index.js' ;
5
6
import { tutorialkitCore } from './vite-plugins/core.js' ;
@@ -59,13 +60,21 @@ export interface Options {
59
60
*/
60
61
scope : string ;
61
62
} ;
63
+
64
+ /**
65
+ * Expressive code plugins.
66
+ *
67
+ * @default []
68
+ */
69
+ expressiveCodePlugins ?: ExpressiveCodePlugin [ ] ;
62
70
}
63
71
64
72
export default function createPlugin ( {
65
73
defaultRoutes = true ,
66
74
components,
67
75
isolation,
68
76
enterprise,
77
+ expressiveCodePlugins = [ ] ,
69
78
} : Options = { } ) : AstroIntegration {
70
79
const webcontainerFiles = new WebContainerFiles ( ) ;
71
80
@@ -137,7 +146,11 @@ export default function createPlugin({
137
146
138
147
// inject the additional integrations right after ours
139
148
const selfIndex = config . integrations . findIndex ( ( integration ) => integration . name === '@tutorialkit/astro' ) ;
140
- config . integrations . splice ( selfIndex + 1 , 0 , ...extraIntegrations ( { root : fileURLToPath ( config . root ) } ) ) ;
149
+ config . integrations . splice (
150
+ selfIndex + 1 ,
151
+ 0 ,
152
+ ...extraIntegrations ( { root : fileURLToPath ( config . root ) , expressiveCodePlugins } ) ,
153
+ ) ;
141
154
} ,
142
155
'astro:config:done' ( { config } ) {
143
156
_config = config ;
Original file line number Diff line number Diff line change @@ -4,14 +4,20 @@ import react from '@astrojs/react';
4
4
import { pluginCollapsibleSections } from '@expressive-code/plugin-collapsible-sections' ;
5
5
import { pluginLineNumbers } from '@expressive-code/plugin-line-numbers' ;
6
6
import { getInlineContentForPackage } from '@tutorialkit/theme' ;
7
- import expressiveCode from 'astro-expressive-code' ;
7
+ import expressiveCode , { type ExpressiveCodePlugin } from 'astro-expressive-code' ;
8
8
import UnoCSS from 'unocss/astro' ;
9
9
10
- export function extraIntegrations ( { root } : { root : string } ) {
10
+ export function extraIntegrations ( {
11
+ root,
12
+ expressiveCodePlugins = [ ] ,
13
+ } : {
14
+ root : string ;
15
+ expressiveCodePlugins ?: ExpressiveCodePlugin [ ] ;
16
+ } ) {
11
17
return [
12
18
react ( ) ,
13
19
expressiveCode ( {
14
- plugins : [ pluginCollapsibleSections ( ) , pluginLineNumbers ( ) ] ,
20
+ plugins : [ pluginCollapsibleSections ( ) , pluginLineNumbers ( ) , ... expressiveCodePlugins ] ,
15
21
themes : [ 'dark-plus' , 'light-plus' ] ,
16
22
customizeTheme : ( theme ) => {
17
23
const isDark = theme . type === 'dark' ;
You can’t perform that action at this time.
0 commit comments