Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/llms.txt/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { source } from '@/lib/source';
import { siteConfig } from '@/lib/config';
import { llms } from 'fumadocs-core/source/llms';

export const dynamic = 'force-static';

const generator = llms(source);

export function GET() {
const index = generator
.index()
// The shared loader must keep site-relative URLs for the app's own routing,
// so the generated index is absolutized here instead — agents fetch this
// file standalone, with no base URL to resolve against.
.replaceAll('](/', `](${siteConfig.url}/`)
// llms.txt expects a single H1 (ours, below); demote the generator's root
// heading by position rather than by literal text.
.replace(/^# /m, '## ');

const body = [
'# Next Commerce Merchant Documentation',
'',
'> Merchant documentation for Next Commerce (NEXT), an ecommerce platform for direct-to-consumer brands and performance marketers — storefronts, orders, subscriptions, payments, fulfillment, apps, and analytics.',
'',
`Related resources: [Developer Docs](https://developers.nextcommerce.com/) (APIs, themes, campaigns), [Platform Changelog](${siteConfig.url}/changelog), [nextcommerce.com](https://nextcommerce.com) (product and pricing).`,
'',
index,
'',
].join('\n');

return new Response(body, {
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
}
4 changes: 4 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export const siteConfig = {
companyName: 'Next Commerce',
// Canonical origin for absolute links in machine-readable outputs (llms.txt).
// Must match the route in wrangler.jsonc. No trailing slash — consumers
// concatenate `/${path}` onto this value.
url: 'https://docs.nextcommerce.com',
Comment thread
next-devin marked this conversation as resolved.
githubOrg: 'NextCommerceCo',
githubRepo: 'docs',
get githubUrl() {
Expand Down