1 year ago

#366119

test-img

Joji

Convert string read from a local mdx file to a window.document object

I have a next.js project using mdx-bundler'

Is there a way to convert string read from a local mdx file to a window.document object so I can use querySelector to query dom elements?

for example, I have a mdx file like this:

## h2
dfdfd
### h3
#### h4

Now I can read this string "## h2 dfdfd ### h3 #### h4" from my code. Is there a way to convert this string into something that can be feed into new JSDOM() so I can use window.document.querySelector on it to get h2, h3 and h4 elements from the mdx?

next.js

server-side-rendering

jsdom

mdxjs

0 Answers

Your Answer

Accepted video resources