'use server'; // app/(api)/sitemap/route.ts import { NextResponse } from 'next/server'; import { productCategoriesData } from '../product_categories/data'; import { host } from '@/config'; const pages = [ '/', '/about-us', '/contact-us', '/blog', '/product-categories', '/projects', ]; const locales = ['en', 'fa']; export async function GET() { try { pages.push( ...productCategoriesData.map( (productCategory) => `/product-categories/${productCategory.id}`, ), ); const urls = pages.flatMap((page) => locales.map((locale) => { const loc = `/${locale}`; return ` ${host}${loc}${page} weekly 0.8 `; }), ); const xml = ` ${urls.join('\n')} `; return new NextResponse(xml, { headers: { 'Content-Type': 'application/xml', }, }); } catch (err) { console.error('Sitemap generation failed:', err); return new NextResponse('Internal Server Errorsssssss', { status: 500 }); } }