|
1 | 1 | import { MetadataRoute } from 'next'; |
2 | | -import { generateSitemapData } from '@/lib/metadata'; |
| 2 | +import { getBlogPosts } from '@/lib/api/blog'; |
| 3 | +import type { BlogPost } from '@/types/blog'; |
3 | 4 |
|
4 | | -export default function sitemap(): MetadataRoute.Sitemap { |
5 | | - const basePages = generateSitemapData(); |
| 5 | +export default async function sitemap(): Promise<MetadataRoute.Sitemap> { |
| 6 | + // Fetch real blog posts from API |
| 7 | + let blogPosts: MetadataRoute.Sitemap = []; |
| 8 | + try { |
| 9 | + const response = await getBlogPosts({ |
| 10 | + status: 'PUBLISHED', |
| 11 | + limit: 1000, // Fetch all published posts |
| 12 | + }); |
| 13 | + blogPosts = response.data.map((post: BlogPost) => ({ |
| 14 | + url: `https://boundlessfi.xyz/blog/${post.slug}`, |
| 15 | + lastModified: new Date(post.updatedAt || post.publishedAt), |
| 16 | + changeFrequency: 'monthly' as const, |
| 17 | + priority: 0.7, |
| 18 | + })); |
| 19 | + } catch { |
| 20 | + // Silently fail if fetch fails, return empty array |
| 21 | + } |
6 | 22 |
|
7 | | - // Add blog posts to sitemap (in a real app, you'd fetch these from your CMS/database) |
8 | | - const blogPosts = [ |
| 23 | + const baseUrl = 'https://boundlessfi.xyz'; |
| 24 | + return [ |
9 | 25 | { |
10 | | - url: 'https://boundlessfi.xyz/blog/getting-started-with-boundless', |
| 26 | + url: baseUrl, |
11 | 27 | lastModified: new Date(), |
12 | | - changeFrequency: 'monthly' as const, |
13 | | - priority: 0.7, |
| 28 | + changeFrequency: 'weekly', |
| 29 | + priority: 1.0, |
14 | 30 | }, |
15 | 31 | { |
16 | | - url: 'https://boundlessfi.xyz/blog/milestone-based-funding-guide', |
| 32 | + url: `${baseUrl}/about`, |
17 | 33 | lastModified: new Date(), |
18 | | - changeFrequency: 'monthly' as const, |
19 | | - priority: 0.7, |
| 34 | + changeFrequency: 'monthly', |
| 35 | + priority: 0.8, |
20 | 36 | }, |
21 | 37 | { |
22 | | - url: 'https://boundlessfi.xyz/blog/stellar-blockchain-benefits', |
| 38 | + url: `${baseUrl}/blog`, |
23 | 39 | lastModified: new Date(), |
24 | | - changeFrequency: 'monthly' as const, |
25 | | - priority: 0.7, |
| 40 | + changeFrequency: 'weekly', |
| 41 | + priority: 0.9, |
26 | 42 | }, |
| 43 | + { |
| 44 | + url: `${baseUrl}/projects`, |
| 45 | + lastModified: new Date(), |
| 46 | + changeFrequency: 'weekly', |
| 47 | + priority: 0.9, |
| 48 | + }, |
| 49 | + { |
| 50 | + url: `${baseUrl}/me`, |
| 51 | + lastModified: new Date(), |
| 52 | + changeFrequency: 'monthly', |
| 53 | + priority: 0.6, |
| 54 | + }, |
| 55 | + ...blogPosts, |
27 | 56 | ]; |
28 | | - |
29 | | - return [...basePages, ...blogPosts]; |
30 | 57 | } |
0 commit comments