stack/docs
Madison 9030eee4dc
[Docs][Util] - LLMs markdown with accept header (#1010)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->


LLMs are served the .mdx file, rather than any HTML, this is done with
the accept header.

<img width="570" height="179" alt="image"
src="https://github.com/user-attachments/assets/044f1477-4983-4c4c-8b3b-7a843bfb56a1"
/>

HTML still accessible, but `text/html` must be first in the accept
header:

<img width="570" height="147" alt="image"
src="https://github.com/user-attachments/assets/db516335-517d-488c-a58f-fc0d024badd9"
/>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Docs and API endpoints now honor Accept headers to deliver Markdown
when clients prefer text/markdown or text/plain; other requests continue
to receive HTML.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds middleware that rewrites /docs and /api requests to LLM-focused
markdown when Accept prefers text/plain or text/markdown over text/html.
> 
> - **Docs Middleware (`docs/src/middleware.ts`)**:
>   - Detects `/docs` and `/api` requests (excluding `.mdx`).
> - Parses `Accept` header; if `text/plain` or `text/markdown` appears
before `text/html`, rewrites to `/llms.mdx...` while preserving query
params.
>   - Adds `config.matcher` for `/docs/:path*` and `/api/:path*`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
837b218b37. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
2025-11-12 14:31:03 -06:00
..
code-examples [Docs][Util][Content] - refactor docs to single source (#919) 2025-10-20 12:42:46 -05:00
content Launch checklist redesign (#1009) 2025-11-11 08:51:33 +05:30
lib [Docs][Site] + [Dashboard][UI] - Adds docs to Stack Companion (#869) 2025-10-30 20:01:30 -05:00
public [Docs][Content] - MCP installation instructions (#915) 2025-10-10 13:31:48 -05:00
scripts [Docs][Util][Content] - refactor docs to single source (#919) 2025-10-20 12:42:46 -05:00
src [Docs][Util] - LLMs markdown with accept header (#1010) 2025-11-12 14:31:03 -06:00
templates Customizable ports (#962) 2025-10-20 15:24:47 -07:00
templates-api Rename offer to product, offer group to product catalog (#914) 2025-10-04 02:28:28 -07:00
templates-python [Docs][Content][UI] - JWT docs and JWT component (#905) 2025-09-29 13:05:33 -05:00
.env.development Customizable ports (#962) 2025-10-20 15:24:47 -07:00
.eslintrc.json New docs (#698) 2025-06-20 13:30:01 -07:00
.gitignore [Docs][Site] + [Dashboard][UI] - Adds docs to Stack Companion (#869) 2025-10-30 20:01:30 -05:00
CHANGELOG.md chore: update package versions 2025-11-10 12:37:35 -08:00
cli.json New docs (#698) 2025-06-20 13:30:01 -07:00
next.config.mjs [Docs][Site] + [Dashboard][UI] - Adds docs to Stack Companion (#869) 2025-10-30 20:01:30 -05:00
package.json chore: update package versions 2025-11-10 12:37:35 -08:00
postcss.config.mjs New docs (#698) 2025-06-20 13:30:01 -07:00
README.md New docs (#698) 2025-06-20 13:30:01 -07:00
source.config.ts [Docs][Site] + [Dashboard][UI] - Adds docs to Stack Companion (#869) 2025-10-30 20:01:30 -05:00
tsconfig.json New docs (#698) 2025-06-20 13:30:01 -07:00

stack-docs

This is a Next.js application generated with Create Fumadocs.

Run development server:

npm run dev
# or
pnpm dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

Explore

In the project, you can see:

  • lib/source.ts: Code for content source adapter, loader() provides the interface to access your content.
  • app/layout.config.tsx: Shared options for layouts, optional but preferred to keep.
Route Description
app/(home) The route group for your landing page and other pages.
app/docs The documentation layout and pages.
app/api The documentation for API pages.
app/api/search/route.ts The Route Handler for search.

Fumadocs MDX

A source.config.ts config file has been included, you can customise different options like frontmatter schema.

Read the Introduction for further details.

Learn More

To learn more about Next.js and Fumadocs, take a look at the following resources: