Files
meezi/web/koja/src/app/sitemap.ts
T

50 lines
1.3 KiB
TypeScript
Raw Normal View History

import type { MetadataRoute } from "next";
import { getAllCafeSlugs } from "@/lib/api";
const BASE = process.env.NEXT_PUBLIC_SITE_URL ?? "https://find.meezi.ir";
const LOCALES = ["fa", "en"];
const CITIES = [
"tehran", "isfahan", "mashhad", "shiraz", "tabriz",
"karaj", "ahvaz", "qom", "rasht", "kermanshah",
];
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const slugs = await getAllCafeSlugs();
const staticPages = LOCALES.flatMap((locale) => [
{
url: `${BASE}/${locale}`,
lastModified: new Date(),
changeFrequency: "daily" as const,
priority: 1.0,
},
{
url: `${BASE}/${locale}/search`,
lastModified: new Date(),
changeFrequency: "daily" as const,
priority: 0.8,
},
]);
const cityPages = LOCALES.flatMap((locale) =>
CITIES.map((city) => ({
url: `${BASE}/${locale}/city/${city}`,
lastModified: new Date(),
changeFrequency: "weekly" as const,
priority: 0.7,
}))
);
const cafePages = LOCALES.flatMap((locale) =>
slugs.map((slug) => ({
url: `${BASE}/${locale}/cafe/${slug}`,
lastModified: new Date(),
changeFrequency: "weekly" as const,
priority: 0.9,
}))
);
return [...staticPages, ...cityPages, ...cafePages];
}