File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 11import { fileURLToPath } from 'node:url' ;
22import type { AstroConfig , AstroIntegration } from 'astro' ;
3+ import type { ExpressiveCodePlugin } from 'astro-expressive-code' ;
34import { extraIntegrations } from './integrations.js' ;
45import { updateMarkdownConfig } from './remark/index.js' ;
56import { tutorialkitCore } from './vite-plugins/core.js' ;
@@ -59,13 +60,21 @@ export interface Options {
5960 */
6061 scope : string ;
6162 } ;
63+
64+ /**
65+ * Expressive code plugins.
66+ *
67+ * @default []
68+ */
69+ expressiveCodePlugins ?: ExpressiveCodePlugin [ ] ;
6270}
6371
6472export default function createPlugin ( {
6573 defaultRoutes = true ,
6674 components,
6775 isolation,
6876 enterprise,
77+ expressiveCodePlugins = [ ] ,
6978} : Options = { } ) : AstroIntegration {
7079 const webcontainerFiles = new WebContainerFiles ( ) ;
7180
@@ -137,7 +146,11 @@ export default function createPlugin({
137146
138147 // inject the additional integrations right after ours
139148 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+ ) ;
141154 } ,
142155 'astro:config:done' ( { config } ) {
143156 _config = config ;
Original file line number Diff line number Diff line change @@ -4,14 +4,20 @@ import react from '@astrojs/react';
44import { pluginCollapsibleSections } from '@expressive-code/plugin-collapsible-sections' ;
55import { pluginLineNumbers } from '@expressive-code/plugin-line-numbers' ;
66import { getInlineContentForPackage } from '@tutorialkit/theme' ;
7- import expressiveCode from 'astro-expressive-code' ;
7+ import expressiveCode , { type ExpressiveCodePlugin } from 'astro-expressive-code' ;
88import UnoCSS from 'unocss/astro' ;
99
10- export function extraIntegrations ( { root } : { root : string } ) {
10+ export function extraIntegrations ( {
11+ root,
12+ expressiveCodePlugins = [ ] ,
13+ } : {
14+ root : string ;
15+ expressiveCodePlugins ?: ExpressiveCodePlugin [ ] ;
16+ } ) {
1117 return [
1218 react ( ) ,
1319 expressiveCode ( {
14- plugins : [ pluginCollapsibleSections ( ) , pluginLineNumbers ( ) ] ,
20+ plugins : [ pluginCollapsibleSections ( ) , pluginLineNumbers ( ) , ... expressiveCodePlugins ] ,
1521 themes : [ 'dark-plus' , 'light-plus' ] ,
1622 customizeTheme : ( theme ) => {
1723 const isDark = theme . type === 'dark' ;
You can’t perform that action at this time.
0 commit comments