File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ type CodeHikeConfig = {
16
16
lineNumbers ?: boolean
17
17
}
18
18
19
- export function remarkCodeHike ( config : CodeHikeConfig ) {
19
+ export function remarkCodeHike (
20
+ unsafeConfig : CodeHikeConfig
21
+ ) {
20
22
return async ( tree : Node ) => {
21
23
// TODO add opt-in config
22
24
let hasCodeHikeImport = false
@@ -30,6 +32,8 @@ export function remarkCodeHike(config: CodeHikeConfig) {
30
32
}
31
33
} )
32
34
35
+ const config = addConfigDefaults ( unsafeConfig )
36
+
33
37
addConfig ( tree as Parent , config )
34
38
35
39
if ( ! hasCodeHikeImport ) {
@@ -52,6 +56,12 @@ export function remarkCodeHike(config: CodeHikeConfig) {
52
56
}
53
57
}
54
58
59
+ function addConfigDefaults (
60
+ config : Partial < CodeHikeConfig > | undefined
61
+ ) : CodeHikeConfig {
62
+ return { ...config , theme : config ?. theme || { } }
63
+ }
64
+
55
65
function addConfig ( tree : Parent , config : CodeHikeConfig ) {
56
66
tree . children . unshift ( {
57
67
type : "mdxjsEsm" ,
You can’t perform that action at this time.
0 commit comments