Skip to content

Commit 713a523

Browse files
committed
convert svg to hast reps
this commit completely removes all kinds of html templating I had going on in the code Signed-off-by: rishichawda <[email protected]>
1 parent 469e7a0 commit 713a523

File tree

5 files changed

+390
-146
lines changed

5 files changed

+390
-146
lines changed

index.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { visit } from 'unist-util-visit'
22
import type { Node, Parent } from 'unist'
33
import type { Blockquote, Paragraph, Text } from 'mdast'
4-
import { NOTE_TYPES } from './lib/types/index.js'
54
import { styles } from './lib/styles.js'
65
import { createNoteStructure } from './lib/node-structure.js'
6+
import { VALID_NOTE_TYPES, ValidNoteType } from './lib/icons-hast.js'
77

88
export default function remarkNotes() {
99
let hasInjectedStyles = false
@@ -37,10 +37,10 @@ export default function remarkNotes() {
3737
const match = textNode.value.match(/^\[!(\w+)\]/)
3838
if (!match) return
3939

40-
const noteType = match[1].toLowerCase()
40+
const noteType = match[1].toLowerCase() as ValidNoteType
4141

4242
// Only transform if it's a recognized note type
43-
if (!(noteType in NOTE_TYPES)) return
43+
if (!VALID_NOTE_TYPES.includes(noteType)) return
4444

4545
// Clone children to preserve original markdown structure
4646
const children = [...node.children]
@@ -61,12 +61,8 @@ export default function remarkNotes() {
6161
}
6262
}
6363

64-
// Get the icon for this note type
65-
const noteConfig = NOTE_TYPES[noteType];
66-
const iconSvg = noteConfig.icon;
67-
68-
// Create the note structure using proper mdast nodes
69-
const noteContainer = createNoteStructure(noteType, iconSvg, children);
64+
// Create the note structure using proper mdast nodes (with hast-converted SVG icons)
65+
const noteContainer = createNoteStructure(noteType, children);
7066

7167
// Replace the blockquote with the container
7268
(parent as Parent).children[index] = noteContainer;

0 commit comments

Comments
 (0)