Skip to content

[P2] Add raw markdown and content negotiation recipes #43

@KayleeWilliams

Description

@KayleeWilliams

Problem

Leadtype already generates flattened markdown mirrors, but framework integration still requires users to manually wire routes. This route layer is central to Leadtype's agent-readability story and should be easier to adopt.

Expected behavior:

  • /docs/foo serves human HTML through the host app.
  • /docs/foo.md serves flattened markdown.
  • Accept: text/markdown can return flattened markdown where practical.
  • /llms.txt links resolve to markdown-friendly URLs.

Proposal

Add first-class raw markdown and content negotiation recipes per framework, supported by small core helpers.

Possible core helper:

resolveMarkdownAsset({
  slug,
  collection: "docs",
  manifest,
});

The core helper should return plain data: status, content type, body, path metadata, and cache metadata. Framework adapters/recipes can translate that into the host's response object.

Framework Integration Notes

  • Next.js: app/docs/[[...slug]]/route.ts or explicit markdown route.
  • Nuxt: server/routes/docs/[...slug].md.get.ts and/or Nitro middleware.
  • SvelteKit: src/routes/docs/[...slug]/+server.ts for content negotiation and an explicit .md route if verified in a fixture.
  • Astro: endpoint route such as src/pages/docs/[...slug].md.ts.
  • Cloudflare Workers: Worker handler using generated artifacts.
  • TanStack Start: server route/function recipe.

Acceptance Criteria

  • A core helper resolves generated markdown assets without framework dependencies.
  • Each framework recipe returns text/markdown; charset=utf-8.
  • Explicit .md URLs are supported consistently where framework routing allows.
  • Accept: text/markdown behavior is documented as optional/conservative.
  • /llms.txt generated links point at markdown-friendly routes.
  • Recipes include verification steps for human HTML and markdown output.

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