(node)
| 59 | } |
| 60 | |
| 61 | function getSections(node) { |
| 62 | let sections = [] |
| 63 | |
| 64 | for (let child of node.children ?? []) { |
| 65 | if (child.type === 'element' && child.tagName === 'h2') { |
| 66 | sections.push(`{ |
| 67 | title: ${JSON.stringify(toString(child))}, |
| 68 | id: ${JSON.stringify(child.properties.id)}, |
| 69 | ...${child.properties.annotation} |
| 70 | }`) |
| 71 | } else if (child.children) { |
| 72 | sections.push(...getSections(child)) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return sections |
| 77 | } |
| 78 | |
| 79 | export const rehypePlugins = [ |
| 80 | mdxAnnotations.rehype, |