81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
import { MetadataRoute } from 'next';
|
|
import { getProjects } from '@/app/actions';
|
|
import { slugify } from '@/lib/utils';
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
const baseUrl = 'https://ayris.tech';
|
|
|
|
const staticUrls: MetadataRoute.Sitemap = [
|
|
{
|
|
url: `${baseUrl}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 1,
|
|
},
|
|
{
|
|
url: `${baseUrl}/en`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 1,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 1,
|
|
},
|
|
{
|
|
url: `${baseUrl}/en/blog`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 0.8,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr/blog`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 0.8,
|
|
},
|
|
{
|
|
url: `${baseUrl}/en/work`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.8,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr/work`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.8,
|
|
},
|
|
];
|
|
|
|
try {
|
|
const projects = await getProjects();
|
|
const uniqueTags = Array.from(new Set(projects.map((p: any) => p.tag)));
|
|
|
|
const expertiseUrls: MetadataRoute.Sitemap = uniqueTags.flatMap((tag) => {
|
|
if (typeof tag !== 'string') return [];
|
|
const slug = slugify(tag);
|
|
return [
|
|
{
|
|
url: `${baseUrl}/en/expertise/${slug}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.7,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr/expertise/${slug}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.7,
|
|
}
|
|
];
|
|
});
|
|
|
|
return [...staticUrls, ...expertiseUrls];
|
|
} catch(e) {
|
|
return staticUrls;
|
|
}
|
|
}
|