feat: implement programmatic SEO infrastructure with localized service pages
This commit is contained in:
@@ -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 [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user