Some checks failed
Build and Deploy Next.js Blog to Production / 🔍 Code Quality Checks (push) Failing after 18s
Build and Deploy Next.js Blog to Production / 🏗️ Build and Push Docker Image (push) Has been skipped
Build and Deploy Next.js Blog to Production / 🚀 Deploy to Production (push) Has been skipped
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { MetadataRoute } from 'next'
|
|
import { getAllPosts } from '@/lib/markdown'
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3030'
|
|
|
|
// Get all blog posts
|
|
const posts = await getAllPosts(false)
|
|
|
|
// Generate sitemap entries for blog posts
|
|
const blogPosts: MetadataRoute.Sitemap = posts.map(post => ({
|
|
url: `${baseUrl}/blog/${post.slug}`,
|
|
lastModified: new Date(post.frontmatter.date),
|
|
changeFrequency: 'monthly' as const,
|
|
priority: 0.8,
|
|
}))
|
|
|
|
// Static pages
|
|
const staticPages: MetadataRoute.Sitemap = [
|
|
{
|
|
url: baseUrl,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'daily' as const,
|
|
priority: 1.0,
|
|
},
|
|
{
|
|
url: `${baseUrl}/blog`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'daily' as const,
|
|
priority: 0.9,
|
|
},
|
|
{
|
|
url: `${baseUrl}/about`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly' as const,
|
|
priority: 0.7,
|
|
},
|
|
]
|
|
|
|
return [...staticPages, ...blogPosts]
|
|
}
|