From fa9e3edcd8ff66de7980d13e6e7752848540e188 Mon Sep 17 00:00:00 2001 From: mstfyldz Date: Sat, 30 May 2026 21:49:10 +0300 Subject: [PATCH] feat: add dynamic llms.txt route for AI context --- app/llms.txt/route.ts | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 app/llms.txt/route.ts diff --git a/app/llms.txt/route.ts b/app/llms.txt/route.ts new file mode 100644 index 0000000..3f8a002 --- /dev/null +++ b/app/llms.txt/route.ts @@ -0,0 +1,60 @@ +import { NextResponse } from 'next/server'; +import { prisma } from '@/lib/prisma'; + +export async function GET() { + try { + // Fetch dynamic content from the database + const projects = await prisma.project.findMany({ + orderBy: { num: 'asc' }, + }); + + const blogs = await prisma.blogPost.findMany({ + orderBy: { id: 'desc' }, + }); + + const baseUrl = 'https://ayris.tech'; + + // Build the llms.txt content + let content = `# Ayris Tech + +Ayris Tech delivers enterprise-grade digital transformation. We build the impossible for the next generation of business using AI, Blockchain, and modern web technologies. + +## Core Navigation +- [Home](${baseUrl}/en) +- [Work/Projects](${baseUrl}/en/work) +- [Blog](${baseUrl}/en/blog) +- [Contact](${baseUrl}/en/contact) + +## Projects +`; + + if (projects.length > 0) { + for (const p of projects) { + content += `- [${p.title}](${baseUrl}/en/work/${p.slug}): ${p.desc}\n`; + } + } else { + content += `No projects found.\n`; + } + + content += `\n## Blog Posts\n`; + if (blogs.length > 0) { + for (const b of blogs) { + content += `- [${b.enTitle}](${baseUrl}/en/blog/${b.slug}): ${b.enExcerpt}\n`; + } + } else { + content += `No blog posts found.\n`; + } + + content += `\n---\n*Generated dynamically from Ayris Tech Database*`; + + return new NextResponse(content, { + headers: { + 'Content-Type': 'text/plain; charset=utf-8', + 'Cache-Control': 'public, max-age=3600, s-maxage=3600, stale-while-revalidate=86400', + }, + }); + } catch (error) { + console.error('Error generating llms.txt:', error); + return new NextResponse('Error generating llms.txt', { status: 500 }); + } +}