INNER CODE UNIT · TypeScript

matchesQuery

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

export function matchesQuery(resource: Resource, query: string) {
  if (!query) return true
  const q = query.trim().toLowerCase()
  if (!q) return true
  return [resource.title, resource.description, resource.category, resource.subcategory ?? '', resource.url, resourceHost(resource.url)].join(' ').toLowerCase().includes(q)
}

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 ''
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…