This commit is contained in:
+10
-7
@@ -2,6 +2,7 @@ import type { MetadataRoute } from "next";
|
||||
import { unstable_noStore as noStore } from "next/cache";
|
||||
|
||||
import { routing } from "@/i18n/routing";
|
||||
import { getSiteSettings } from "@/lib/app-config";
|
||||
import { getLocalizedPath } from "@/lib/locale";
|
||||
import { getPublishedPortfolioProjects } from "@/lib/portfolio";
|
||||
|
||||
@@ -15,10 +16,11 @@ function toAbsoluteUrl(pathname: string): string {
|
||||
|
||||
function buildLocalizedEntries(
|
||||
pathname: string,
|
||||
defaultLocale: "de" | "en" | "ar",
|
||||
options?: Pick<MetadataRoute.Sitemap[number], "changeFrequency" | "priority" | "lastModified">,
|
||||
): MetadataRoute.Sitemap {
|
||||
return routing.locales.map((locale) => ({
|
||||
url: toAbsoluteUrl(getLocalizedPath(locale, pathname)),
|
||||
url: toAbsoluteUrl(getLocalizedPath(locale, pathname, defaultLocale)),
|
||||
lastModified: options?.lastModified,
|
||||
changeFrequency: options?.changeFrequency,
|
||||
priority: options?.priority,
|
||||
@@ -27,6 +29,7 @@ function buildLocalizedEntries(
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
noStore();
|
||||
const siteSettings = await getSiteSettings();
|
||||
|
||||
let projects: Awaited<ReturnType<typeof getPublishedPortfolioProjects>> = [];
|
||||
|
||||
@@ -41,30 +44,30 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
);
|
||||
|
||||
return [
|
||||
...buildLocalizedEntries("/", {
|
||||
...buildLocalizedEntries("/", siteSettings.defaultLocale, {
|
||||
changeFrequency: "weekly",
|
||||
priority: 1,
|
||||
}),
|
||||
...buildLocalizedEntries("/about", {
|
||||
...buildLocalizedEntries("/about", siteSettings.defaultLocale, {
|
||||
changeFrequency: "monthly",
|
||||
priority: 0.8,
|
||||
}),
|
||||
...buildLocalizedEntries("/portfolio", {
|
||||
...buildLocalizedEntries("/portfolio", siteSettings.defaultLocale, {
|
||||
changeFrequency: "weekly",
|
||||
priority: 0.9,
|
||||
}),
|
||||
...categories.flatMap((category) =>
|
||||
buildLocalizedEntries(`/portfolio/category/${category.slug}`, {
|
||||
buildLocalizedEntries(`/portfolio/category/${category.slug}`, siteSettings.defaultLocale, {
|
||||
changeFrequency: "weekly",
|
||||
priority: 0.8,
|
||||
}),
|
||||
),
|
||||
...buildLocalizedEntries("/contact", {
|
||||
...buildLocalizedEntries("/contact", siteSettings.defaultLocale, {
|
||||
changeFrequency: "monthly",
|
||||
priority: 0.7,
|
||||
}),
|
||||
...projects.flatMap((project) =>
|
||||
buildLocalizedEntries(`/portfolio/${project.slug}`, {
|
||||
buildLocalizedEntries(`/portfolio/${project.slug}`, siteSettings.defaultLocale, {
|
||||
lastModified: project.publishedAt ?? undefined,
|
||||
changeFrequency: "monthly",
|
||||
priority: 0.8,
|
||||
|
||||
Reference in New Issue
Block a user