Skip to content

[P4] Add typed query API over docs metadata #49

@KayleeWilliams

Description

@KayleeWilliams

Problem

Consumers often need sidebars, related pages, filtered views, changelogs, API indexes, and static route params. Today they need to work directly with manifests or source primitives.

Leadtype should expose a typed query API over source metadata and generated manifests without introducing a runtime database.

Proposal

Add a small query API over docs metadata.

Example:

const referencePages = await queryDocs("docs")
  .where("group", "=", "reference")
  .order("order", "asc")
  .all();

const page = await queryDocs("docs").path("/docs/reference/cli").first();

Core Behavior

  • Query local source metadata at build/server time.
  • Support collections.
  • Avoid runtime SQL/database requirements.
  • Use generated manifests where appropriate.
  • Preserve duplicate slug/path validation.

Initial API candidates:

  • where
  • order
  • limit
  • path
  • slug
  • all
  • first

Framework Integration Notes

Use query results in native lifecycle points:

  • Next.js: generateStaticParams().
  • SvelteKit: entries() and server load.
  • Astro: getStaticPaths().
  • Nuxt: route generation/Nitro route data.
  • TanStack Start: route manifests/loaders.

Acceptance Criteria

  • Query API has no framework dependency.
  • Query results can power sidebars without custom manifest parsing.
  • Querying works across multiple collections.
  • Collection schema types flow into query result types where possible.
  • Framework recipes show native route/static-param generation.
  • Duplicate paths/slugs fail clearly.

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