INNER CODE UNIT · TypeScript

textOf

ahmet/awesome-web3 · lib/catalog.ts:69

function textOf(node: MdNode | undefined): string {
  if (!node) return ''
  if (node.type === 'text' || node.type === 'inlineCode') {
    return node.value ?? ''
  }
  if (node.children?.length) {
    return node.children.map(textOf).join('')
  }
  return ''
}

function firstLink(nodes: MdNode[]): { title: string; url: string } | null {
  for (const node of nodes) {
    if (node.type === 'link' && node.url) {
      return { title: textOf(node).trim(), url: node.url }
    }
    if (node.children) {
      const nested = firstLink(node.children)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…