1
import {
2
source,
3
- referenceSource,
3
+ getReferenceSource,
4
examplesSource,
5
toolkitsSource,
6
getLLMText,
374
}
375
376
// Map URL prefixes to their sources
377
+// Note: 'reference' is handled specially below with async getReferenceSource()
378
const sources = [
379
{ prefix: 'docs', source },
379
- { prefix: 'reference', source: referenceSource },
380
{ prefix: 'examples', source: examplesSource },
381
{ prefix: 'toolkits', source: toolkitsSource },
382
];
430
const { slug = [] } = await params;
431
const [prefix, ...rest] = slug;
432
433
- // Find the matching source
434
- const match = sources.find((s) => s.prefix === prefix);
435
- if (!match) notFound();
433
+ // Handle 'reference' specially - uses async getReferenceSource() for OpenAPI pages
434
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
435
+ let pageSource: any;
436
+ if (prefix === 'reference') {
437
+ pageSource = await getReferenceSource();
438
+ } else {
439
+ const match = sources.find((s) => s.prefix === prefix);
440
+ if (!match) notFound();
441
+ pageSource = match.source;
442
+ }
443
444
// Get the page from that source (MDX pages)
445
let page;
446
try {
440
- page = match.source.getPage(rest.length > 0 ? rest : undefined);
447
+ page = pageSource.getPage(rest.length > 0 ? rest : undefined);
448
} catch (e) {
449
console.error('Error in getPage:', e);
450
page = null;
519
throw e;
520
}
521
console.error('Unexpected error in llms.mdx route:', e);
515
- const errorMessage = e instanceof Error ? e.message : String(e);
516
- const errorStack = e instanceof Error ? e.stack : '';
522
return new Response(
518
- `# Error\n\nAn error occurred while generating the markdown content.\n\n**Error:** ${errorMessage}\n\n**Stack:**\n\`\`\`\n${errorStack}\n\`\`\``,
523
+ `# Error\n\nAn error occurred while generating the markdown content.`,
524
{
520
- status: 200, // Return 200 so we can see the error
525
+ status: 500,
526
headers: {
527
'Content-Type': 'text/markdown; charset=utf-8',
528
},