docs: handle Card and CardList components in cross-links plugin (#7338)

This commit is contained in:
Shahed Nasser
2024-05-16 09:40:42 +03:00
committed by GitHub
parent 490586f566
commit 1160a34f3d
6 changed files with 361 additions and 113 deletions
@@ -0,0 +1,20 @@
import { UnistNodeWithData } from "../types/index.js"
export default function getAttribute(
node: UnistNodeWithData,
attrName: string
) {
const attributeIndex = node.attributes?.findIndex(
(attribute) => attribute.name === attrName
)
if (attributeIndex === undefined || attributeIndex === -1) {
return
}
const attribute = node.attributes![attributeIndex]
if (!attribute) {
return
}
return attribute
}