searchResults

tcmts.share.searchResults · #tj7je2bs · term · runs on the server

uses tcmts.cli.pages.find, which uses tcmts.cli.search.searchByType, which uses node:path

What the finder finds: by name, words in docs, or a type, each with its page.

import { find } from "#codebase/tcmts/cli/pages";
import { codeHref } from "#codebase/tcmts/share";
import type { Share } from "#codebase/tcmts/share";

export function searchResults(s: Share, q: string) {
  return find(s.cb, q, () => "")
    .filter((r) => r.path)
    .map((r) => ({
      path: r.path,
      match: r.match,
      signature: r.kind === "file" ? "file" : r.signature,
      detail: r.detail ?? "",
      href: codeHref(r.path),
    }));
}

uses

used by