feat: implement programmatic SEO routes and optimize meta tags
This commit is contained in:
+32
-2
@@ -1,9 +1,11 @@
|
||||
import { MetadataRoute } from 'next';
|
||||
import { getProjects } from '@/app/actions';
|
||||
import { slugify } from '@/lib/utils';
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const baseUrl = 'https://ayris.tech';
|
||||
|
||||
return [
|
||||
const staticUrls: MetadataRoute.Sitemap = [
|
||||
{
|
||||
url: `${baseUrl}`,
|
||||
lastModified: new Date(),
|
||||
@@ -47,4 +49,32 @@ export default function sitemap(): MetadataRoute.Sitemap {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user