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 = {
1616 lineNumbers ?: boolean
1717}
1818
19- export function remarkCodeHike ( config : CodeHikeConfig ) {
19+ export function remarkCodeHike (
20+ unsafeConfig : CodeHikeConfig
21+ ) {
2022 return async ( tree : Node ) => {
2123 // TODO add opt-in config
2224 let hasCodeHikeImport = false
@@ -30,6 +32,8 @@ export function remarkCodeHike(config: CodeHikeConfig) {
3032 }
3133 } )
3234
35+ const config = addConfigDefaults ( unsafeConfig )
36+
3337 addConfig ( tree as Parent , config )
3438
3539 if ( ! hasCodeHikeImport ) {
@@ -52,6 +56,12 @@ export function remarkCodeHike(config: CodeHikeConfig) {
5256 }
5357}
5458
59+ function addConfigDefaults (
60+ config : Partial < CodeHikeConfig > | undefined
61+ ) : CodeHikeConfig {
62+ return { ...config , theme : config ?. theme || { } }
63+ }
64+
5565function addConfig ( tree : Parent , config : CodeHikeConfig ) {
5666 tree . children . unshift ( {
5767 type : "mdxjsEsm" ,
You can’t perform that action at this time.
0 commit comments