After to digging around a little because my transform function wasn't working like I expected based from the docs example, I thought offering a suggestion would be helpful.
Since the reference a tagName === 'a', I expected just that, a lowercase 'a'. But turns out tagNames are actually uppercase. So maybe one of the following changes?
function transform(node: HTMLElement, children: Node[]): React.ReactNode {
if (node.tagName === 'A') {
return <Link href={node.getAttribute('href')}>{children}</Link>;
}
}
OR
function transform(node: HTMLElement, children: Node[]): React.ReactNode {
if (node.tagName.toLowerCase() === 'a') {
return <Link href={node.getAttribute('href')}>{children}</Link>;
}
}
Hey there! Awesome library!
After to digging around a little because my transform function wasn't working like I expected based from the docs example, I thought offering a suggestion would be helpful.
Since the reference a
tagName
=== 'a', I expected just that, a lowercase 'a'. But turns outtagNames
are actually uppercase. So maybe one of the following changes?OR