cleanup
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
import { MetadataRoute } from 'next';
|
||||
import { getAllPages, getAllPosts, getAllProducts, getAllCategories } from '../lib/data';
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const baseUrl = process.env.SITE_URL || 'https://klz-cables.com';
|
||||
const urls: MetadataRoute.Sitemap = [];
|
||||
|
||||
// Add homepage
|
||||
urls.push({
|
||||
url: baseUrl,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: 'daily',
|
||||
priority: 1,
|
||||
});
|
||||
|
||||
// Add all pages
|
||||
try {
|
||||
const pages = await getAllPages();
|
||||
pages.forEach(page => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/${page.slug}`,
|
||||
lastModified: new Date(page.updatedAt || Date.now()),
|
||||
changeFrequency: 'weekly',
|
||||
priority: 0.8,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch pages for sitemap:', error);
|
||||
}
|
||||
|
||||
// Add blog posts
|
||||
try {
|
||||
const posts = await getAllPosts();
|
||||
posts.forEach(post => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/blog/${post.slug}`,
|
||||
lastModified: new Date(post.updatedAt || Date.now()),
|
||||
changeFrequency: 'weekly',
|
||||
priority: 0.6,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch posts for sitemap:', error);
|
||||
}
|
||||
|
||||
// Add products
|
||||
try {
|
||||
const products = await getAllProducts();
|
||||
products.forEach(product => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/product/${product.slug}`,
|
||||
lastModified: new Date(product.updatedAt || Date.now()),
|
||||
changeFrequency: 'monthly',
|
||||
priority: 0.5,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch products for sitemap:', error);
|
||||
}
|
||||
|
||||
// Add product categories
|
||||
try {
|
||||
const categories = await getAllCategories();
|
||||
categories.forEach(category => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/product-category/${category.slug}`,
|
||||
lastModified: new Date(Date.now()),
|
||||
changeFrequency: 'monthly',
|
||||
priority: 0.4,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch categories for sitemap:', error);
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
Reference in New Issue
Block a user