Skip to content

Commit ea81ba6

Browse files
committed
don't use raw node
Signed-off-by: rishichawda <[email protected]>
1 parent 686131e commit ea81ba6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ export default function remarkNotes(options: RemarkNotesOptions = {}) {
1919

2020
return (tree: Node) => {
2121
// Inject styles at the beginning of the document (only once) if enabled
22+
// Using proper mdast node instead of HTML string for MDX compatibility
2223
if (injectStyles && !hasInjectedStyles) {
2324
const root = tree as Parent
2425
if (root.children) {
26+
// Create a proper mdast node that will be transformed to <style> tag
2527
root.children.unshift({
26-
type: 'html',
27-
value: `<style>${styles}</style>`
28+
type: 'paragraph',
29+
data: {
30+
hName: 'style',
31+
hProperties: {}
32+
},
33+
children: [{
34+
type: 'text',
35+
value: styles
36+
}]
2837
} as any)
2938
hasInjectedStyles = true
3039
}

0 commit comments

Comments
 (0)