fix: update sitemap to use localized slugs for programmatic SEO pages
- Update sitemap.ts to use page.localizedSlugs[locale] for correct URLs - Generate all 40 localized URLs (10 pages × 4 locales) with proper slugs - Remove outdated sitemap-programmatic.xml - Add proper TypeScript type for solutionPages
This commit is contained in:
+10
-8
@@ -1,6 +1,7 @@
|
||||
import { MetadataRoute } from "next";
|
||||
import { getProducts, filterOutBundles } from "@/lib/saleor";
|
||||
import { getAllOilForConcernPages } from "@/lib/programmatic-seo/dataLoader";
|
||||
import type { OilForConcernPage } from "@/lib/programmatic-seo/types";
|
||||
import { SUPPORTED_LOCALES, type Locale } from "@/lib/i18n/locales";
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
||||
@@ -106,7 +107,7 @@ export default async function sitemap(): Promise<SitemapEntry[]> {
|
||||
}
|
||||
}
|
||||
|
||||
let solutionPages: any[] = [];
|
||||
let solutionPages: OilForConcernPage[] = [];
|
||||
try {
|
||||
solutionPages = await getAllOilForConcernPages();
|
||||
} catch (e) {
|
||||
@@ -116,16 +117,17 @@ export default async function sitemap(): Promise<SitemapEntry[]> {
|
||||
const solutionUrls: SitemapEntry[] = [];
|
||||
|
||||
for (const page of solutionPages) {
|
||||
const hreflangs: Record<string, string> = {};
|
||||
for (const locale of SUPPORTED_LOCALES) {
|
||||
const path = locale === "sr" ? `/solutions/${page.slug}` : `/${locale}/solutions/${page.slug}`;
|
||||
hreflangs[locale] = `${baseUrl}${path}`;
|
||||
}
|
||||
const localizedSlug = page.localizedSlugs[locale];
|
||||
const url = `${baseUrl}/${locale}/solutions/${localizedSlug}`;
|
||||
|
||||
const hreflangs: Record<string, string> = {};
|
||||
for (const loc of SUPPORTED_LOCALES) {
|
||||
hreflangs[loc] = `${baseUrl}/${loc}/solutions/${page.localizedSlugs[loc]}`;
|
||||
}
|
||||
|
||||
for (const locale of SUPPORTED_LOCALES) {
|
||||
const localePrefix = locale === "sr" ? "" : `/${locale}`;
|
||||
solutionUrls.push({
|
||||
url: `${baseUrl}${localePrefix}/solutions/${page.slug}`,
|
||||
url,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: "monthly",
|
||||
priority: 0.7,
|
||||
|
||||
Reference in New Issue
Block a user