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 }); } }