feat: implementar SEO completo com sitemap, robots.txt, JSON-LD schema e Google Search Console docs
This commit is contained in:
59
frontend/src/app/sitemap.ts
Normal file
59
frontend/src/app/sitemap.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { MetadataRoute } from 'next';
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const baseUrl = 'https://octto-engenharia.com';
|
||||
const locales = ['', '/en', '/es'];
|
||||
|
||||
// Páginas principais
|
||||
const pages = [
|
||||
{ url: '', changefreq: 'weekly', priority: 1 },
|
||||
{ url: '/servicos', changefreq: 'monthly', priority: 0.8 },
|
||||
{ url: '/projetos', changefreq: 'weekly', priority: 0.8 },
|
||||
{ url: '/contato', changefreq: 'monthly', priority: 0.7 },
|
||||
{ url: '/sobre', changefreq: 'monthly', priority: 0.7 },
|
||||
{ url: '/privacidade', changefreq: 'yearly', priority: 0.5 },
|
||||
{ url: '/termos', changefreq: 'yearly', priority: 0.5 },
|
||||
];
|
||||
|
||||
// Buscar projetos do banco de dados
|
||||
let projects = [];
|
||||
try {
|
||||
const res = await fetch(`${baseUrl}/api/projects`, {
|
||||
next: { revalidate: 3600 }, // Cache por 1 hora
|
||||
});
|
||||
if (res.ok) {
|
||||
projects = await res.json();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erro ao buscar projetos para sitemap:', error);
|
||||
}
|
||||
|
||||
// Gerar URLs
|
||||
const sitemap: MetadataRoute.Sitemap = [];
|
||||
|
||||
// Adicionar páginas principais para cada locale
|
||||
for (const locale of locales) {
|
||||
for (const page of pages) {
|
||||
sitemap.push({
|
||||
url: `${baseUrl}${locale}${page.url}`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: page.changefreq as 'weekly' | 'monthly' | 'yearly',
|
||||
priority: page.priority,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Adicionar páginas de projetos específicos
|
||||
for (const locale of locales) {
|
||||
for (const project of projects) {
|
||||
sitemap.push({
|
||||
url: `${baseUrl}${locale}/projetos/${project.id}`,
|
||||
lastModified: project.updatedAt ? new Date(project.updatedAt) : new Date(),
|
||||
changeFrequency: 'monthly' as const,
|
||||
priority: 0.6,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return sitemap;
|
||||
}
|
||||
Reference in New Issue
Block a user