forked from stackblitz/tutorialkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegrations.ts
More file actions
69 lines (66 loc) · 2.28 KB
/
integrations.ts
File metadata and controls
69 lines (66 loc) · 2.28 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { createRequire } from 'node:module';
import mdx from '@astrojs/mdx';
import react from '@astrojs/react';
import { pluginCollapsibleSections } from '@expressive-code/plugin-collapsible-sections';
import { pluginLineNumbers } from '@expressive-code/plugin-line-numbers';
import { getInlineContentForPackage } from '@tutorialkit/theme';
import expressiveCode, { type ExpressiveCodePlugin, type ThemeObjectOrShikiThemeName } from 'astro-expressive-code';
import UnoCSS from 'unocss/astro';
export function extraIntegrations({
root,
expressiveCodePlugins = [],
expressiveCodeThemes = ['light-plus', 'dark-plus'],
}: {
root: string;
expressiveCodePlugins?: ExpressiveCodePlugin[];
/**
* Themes for Expressive Code.
* Takes a tuple of themes, e.g. `[lightTheme, darkTheme]`.
*/
expressiveCodeThemes?: [ThemeObjectOrShikiThemeName, ThemeObjectOrShikiThemeName];
}) {
return [
react(),
expressiveCode({
plugins: [pluginCollapsibleSections(), pluginLineNumbers(), ...expressiveCodePlugins],
themes: expressiveCodeThemes,
customizeTheme: (theme) => {
const isDark = theme.type === 'dark';
theme.styleOverrides = {
borderColor: 'var(--tk-border-secondary)',
borderWidth: '1px',
borderRadius: 'var(--code-border-radius, 0px)',
frames: {
terminalTitlebarBackground: `var(--tk-background-${isDark ? 'primary' : 'secondary'})`,
terminalTitlebarBorderBottomColor: `var(--tk-background-${isDark ? 'primary' : 'secondary'})`,
editorTabBorderRadius: 'var(--code-border-radius, 0px)',
editorTabBarBackground: `var(--tk-background-${isDark ? 'primary' : 'secondary'})`,
},
};
},
themeCssSelector: (theme) => {
return `[data-theme='${theme.type}']`;
},
defaultProps: {
showLineNumbers: false,
},
styleOverrides: {
frames: {
shadowColor: 'none',
},
},
}),
mdx(),
UnoCSS({
configDeps: ['./theme.ts'],
injectReset: createRequire(root).resolve('@unocss/reset/tailwind.css'),
content: {
inline: getInlineContentForPackage({
name: '@tutorialkit/astro',
pattern: '/dist/default/**/*.astro',
root,
}),
},
}),
];
}