Skip to content

[P1] Add collection config for multi-source docs #42

@KayleeWilliams

Description

@KayleeWilliams

Problem

Leadtype supports docs directories and mounts, but the product model is still mostly "a docs folder." Larger docs systems need to describe multiple content sets with clear schemas, route prefixes, and artifact behavior.

Nuxt Content's collection model is a useful inspiration point, but Leadtype should keep the implementation framework-neutral and artifact-oriented.

Proposal

Introduce collection-style config for source files, route prefixes, schemas, and artifact inclusion.

Example:

export default defineDocsConfig({
  collections: {
    docs: defineCollection({
      source: "docs/**/*.mdx",
      prefix: "/docs",
      schema: docsFrontmatterSchema,
    }),
    changelog: defineCollection({
      source: "changelog/**/*.mdx",
      prefix: "/changelog",
      schema: changelogFrontmatterSchema,
    }),
  },
});

Collections should map cleanly onto current --docs-dir/mount behavior while giving users a typed, explicit mental model.

Core Behavior

  • Collections are framework-neutral.
  • A collection describes source globs, route prefix, schema, and generated-artifact participation.
  • Generated navigation, search, markdown mirrors, llms.txt, and Agent Readability metadata preserve collection route prefixes.

Framework Integration Notes

Adapters/recipes can map collections to native host concepts:

  • Next.js: generateStaticParams().
  • SvelteKit: entries() and server load.
  • Astro: getStaticPaths() and optional Content Collections interop.
  • Nuxt: route generation/Nitro conventions without requiring Nuxt Content.
  • Fumadocs: source adapter shape.

Acceptance Criteria

  • defineCollection() exists and is documented.
  • A project can generate docs and changelog artifacts from one config.
  • Existing single-folder projects require no migration.
  • Existing CLI mount behavior is preserved or mapped cleanly.
  • Invalid frontmatter errors identify the collection and source path.
  • Collection metadata can power framework route/static-param examples.

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