Skip to content

[P4] Improve search ergonomics with framework-native helpers #45

@KayleeWilliams

Description

@KayleeWilliams

Problem

Leadtype has static search internals, but app-facing search adoption can be easier. Users should not have to manually import and coordinate both generated JSON files in every framework.

Nuxt Content's useSearchCollection() is a good ergonomics reference, but Leadtype should preserve its own strengths: static JSON artifacts, edge-safe runtime, framework-neutral core, and optional source-grounded answers.

Proposal

Keep searchDocs() as the core primitive, then add idiomatic framework-facing search helpers.

Core:

searchDocs(index, query, { content });

React/Next/TanStack:

const { search, results, status } = useLeadtypeSearch("docs");

Vue/Nuxt:

const { search, results, status } = useLeadtypeSearch("docs");

Svelte/SvelteKit:

const docsSearch = createLeadtypeSearch({
  indexUrl: "/docs/search-index.json",
  contentUrl: "/docs/search-content.json",
});

Astro:

  • Plain browser helper.
  • Island examples for React/Svelte/Vue.
  • No required framework runtime.

Acceptance Criteria

  • Core searchDocs() remains stable and framework-neutral.
  • Framework helpers load generated search-index.json and search-content.json.
  • Multi-collection search is supported or explicitly designed.
  • Results include title, URL, heading path, snippet, and score.
  • Source-grounded answer streaming remains separate from basic search.
  • Svelte uses stores/runes-style ergonomics rather than React-like hooks.
  • Astro gets a plain helper and island examples instead of a fake hook.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions