()
| 38 | } |
| 39 | |
| 40 | export async function GET() { |
| 41 | const pages = source.getPages(); |
| 42 | |
| 43 | // Generate LLMS.txt content |
| 44 | let txt = `# Zod |
| 45 | |
| 46 | > Zod is a TypeScript-first schema validation library with static type inference. This documentation provides comprehensive coverage of Zod 4's features, API, and usage patterns. |
| 47 | |
| 48 | `; |
| 49 | |
| 50 | // Process each page |
| 51 | for (const page of pages) { |
| 52 | // Skip separator entries that start with "---" |
| 53 | const title = stringifyTitle(page.data.title); |
| 54 | if (title.startsWith("---")) { |
| 55 | continue; |
| 56 | } |
| 57 | |
| 58 | // Create section for each page |
| 59 | txt += `## ${title || "Untitled"}\n\n`; |
| 60 | |
| 61 | // Add main page link with description from frontmatter |
| 62 | const pageUrl = `https://zod.dev${page.url}`; |
| 63 | const description = page.data.description || "Documentation page"; |
| 64 | txt += `- [${title || "Untitled"}](${pageUrl}): ${description}\n`; |
| 65 | |
| 66 | // Add TOC sections for deep linking |
| 67 | if (page.data.toc && page.data.toc.length > 0) { |
| 68 | // Group sections by depth for better organization |
| 69 | const sections = page.data.toc.filter((item: any) => item.depth >= 2 && item.depth <= 4); |
| 70 | |
| 71 | if (sections.length > 0) { |
| 72 | txt += "\n"; |
| 73 | |
| 74 | for (const section of sections) { |
| 75 | const sectionTitle = stringifyTitle(section.title); |
| 76 | if (!sectionTitle) continue; |
| 77 | |
| 78 | const anchor = section.url.replace("#", ""); |
| 79 | const fullUrl = `https://zod.dev${page.url}?id=${anchor}`; |
| 80 | |
| 81 | txt += `- [${sectionTitle}](${fullUrl})\n`; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | txt += "\n"; |
| 87 | } |
| 88 | |
| 89 | txt += `--- |
| 90 | |
| 91 | This documentation covers Zod v4, a TypeScript-first schema validation library. Use the URLs above to access specific pages and sections for detailed information about schema definition, validation, error handling, and advanced patterns. |
| 92 | `; |
| 93 | |
| 94 | return new Response(txt, { |
| 95 | headers: { |
| 96 | "Content-Type": "text/plain; charset=utf-8", |
| 97 | }, |
nothing calls this directly
no test coverage detected