154 lines
3.9 KiB
TypeScript
154 lines
3.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,
|
|
},
|
|
{
|
|
url: `${baseUrl}/en/privacy`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.7,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr/privacy`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.7,
|
|
},
|
|
];
|
|
|
|
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,
|
|
}
|
|
];
|
|
});
|
|
|
|
const workUrls: MetadataRoute.Sitemap = projects.flatMap((p: any) => [
|
|
{
|
|
url: `${baseUrl}/en/work/${p.slug}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.7,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr/work/${p.slug}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.7,
|
|
}
|
|
]);
|
|
|
|
// Blog Posts
|
|
let blogUrls: MetadataRoute.Sitemap = [];
|
|
try {
|
|
const { getBlogPosts } = await import('@/app/actions');
|
|
const posts = await getBlogPosts();
|
|
blogUrls = posts.flatMap((p: any) => [
|
|
{
|
|
url: `${baseUrl}/en/blog/${p.slug}`,
|
|
lastModified: new Date(p.date || new Date()),
|
|
changeFrequency: 'weekly',
|
|
priority: 0.8,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr/blog/${p.slug}`,
|
|
lastModified: new Date(p.date || new Date()),
|
|
changeFrequency: 'weekly',
|
|
priority: 0.8,
|
|
}
|
|
]);
|
|
} catch (err) {
|
|
// Ignore if blog fetching fails
|
|
}
|
|
|
|
// Privacy App Pages
|
|
let privacyUrls: MetadataRoute.Sitemap = [];
|
|
try {
|
|
const { getAllPrivacyApps } = await import('@/data/privacy');
|
|
const privacyApps = getAllPrivacyApps();
|
|
privacyUrls = privacyApps.flatMap((app) => [
|
|
{
|
|
url: `${baseUrl}/en/privacy/${app.slug}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.6,
|
|
},
|
|
{
|
|
url: `${baseUrl}/tr/privacy/${app.slug}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.6,
|
|
},
|
|
]);
|
|
} catch (err) {
|
|
// Ignore if privacy fetching fails
|
|
}
|
|
|
|
return [...staticUrls, ...expertiseUrls, ...workUrls, ...blogUrls, ...privacyUrls];
|
|
} catch(e) {
|
|
return staticUrls;
|
|
}
|
|
}
|