mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-16 20:44:56 +02:00
29 lines
663 B
JavaScript
29 lines
663 B
JavaScript
/**
|
|
* @typedef {import('mdast-util-mdxjs-esm').MdxjsEsmHast} MdxjsEsm
|
|
*
|
|
* @typedef {import('../state.js').State} State
|
|
*/
|
|
|
|
import {attachComments} from 'estree-util-attach-comments'
|
|
|
|
/**
|
|
* Handle an MDX ESM node.
|
|
*
|
|
* @param {MdxjsEsm} node
|
|
* hast node to transform.
|
|
* @param {State} state
|
|
* Info passed around about the current state.
|
|
* @returns {undefined}
|
|
* Nothing.
|
|
*/
|
|
export function mdxjsEsm(node, state) {
|
|
const estree = node.data && node.data.estree
|
|
const comments = (estree && estree.comments) || []
|
|
|
|
if (estree) {
|
|
state.comments.push(...comments)
|
|
attachComments(estree, comments)
|
|
state.esm.push(...estree.body)
|
|
}
|
|
}
|