feat: implement programmatic SEO infrastructure with localized service pages

This commit is contained in:
AyrisAI
2026-05-16 00:55:42 +03:00
parent c5703c060d
commit d0a7205f90
5 changed files with 300 additions and 3 deletions

View File

@@ -97,4 +97,39 @@ export async function getProjectBySlug(slug: string) {
return null;
}
}
export async function getServiceBySlug(slug: string) {
try {
const services = await sql`SELECT * FROM services WHERE slug = ${slug} LIMIT 1`;
return services[0] || null;
} catch (error) {
console.error('Error fetching service:', error);
return null;
}
}
export async function getLocationBySlug(slug: string) {
try {
const locations = await sql`SELECT * FROM locations WHERE slug = ${slug} LIMIT 1`;
return locations[0] || null;
} catch (error) {
console.error('Error fetching location:', error);
return null;
}
}
export async function getProjectsByService(serviceName: string) {
try {
// Search projects where the serviceName is in the title or categories
// serviceName is expected to be something like "Drone Çekimi"
return await sql`
SELECT * FROM projects
WHERE title ILIKE ${'%' + serviceName + '%'}
OR categories::text ILIKE ${'%' + serviceName + '%'}
ORDER BY created_at DESC
LIMIT 4
`;
} catch (error) {
console.error('Error fetching projects by service:', error);
return [];
}
}