📄 production optimizations
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
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
This commit was merged in pull request #8.
This commit is contained in:
41
app/feed.xml/route.ts
Normal file
41
app/feed.xml/route.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { getAllPosts } from '@/lib/markdown'
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
export async function GET() {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3030'
|
||||
const posts = await getAllPosts(false)
|
||||
|
||||
const rss = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>My Blog - Tech, Development & More</title>
|
||||
<link>${baseUrl}</link>
|
||||
<description>Personal blog about software development, technology, and interesting projects</description>
|
||||
<language>ro-RO</language>
|
||||
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
|
||||
<atom:link href="${baseUrl}/feed.xml" rel="self" type="application/rss+xml"/>
|
||||
${posts
|
||||
.slice(0, 20)
|
||||
.map(post => {
|
||||
const postUrl = `${baseUrl}/blog/${post.slug}`
|
||||
return `
|
||||
<item>
|
||||
<title><![CDATA[${post.frontmatter.title}]]></title>
|
||||
<link>${postUrl}</link>
|
||||
<guid isPermaLink="true">${postUrl}</guid>
|
||||
<description><![CDATA[${post.frontmatter.description}]]></description>
|
||||
<pubDate>${new Date(post.frontmatter.date).toUTCString()}</pubDate>
|
||||
<author>${post.frontmatter.author}</author>
|
||||
</item>`
|
||||
})
|
||||
.join('')}
|
||||
</channel>
|
||||
</rss>`
|
||||
|
||||
return new NextResponse(rss, {
|
||||
headers: {
|
||||
'Content-Type': 'application/xml',
|
||||
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate',
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import type { Metadata } from 'next'
|
||||
import { JetBrains_Mono } from 'next/font/google'
|
||||
import './globals.css'
|
||||
import { ThemeProvider } from '@/providers/providers'
|
||||
import '@/lib/env-validation' // Validate environment variables
|
||||
|
||||
const jetbrainsMono = JetBrains_Mono({ subsets: ['latin'], variable: '--font-mono' })
|
||||
|
||||
|
||||
18
app/robots.ts
Normal file
18
app/robots.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { MetadataRoute } from 'next'
|
||||
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3030'
|
||||
|
||||
return {
|
||||
rules: {
|
||||
userAgent: '*',
|
||||
allow: '/',
|
||||
disallow: [
|
||||
'/api/', // Disallow API routes (if any)
|
||||
'/_next/', // Disallow Next.js internals
|
||||
'/admin/', // Disallow admin (if any)
|
||||
],
|
||||
},
|
||||
sitemap: `${baseUrl}/sitemap.xml`,
|
||||
}
|
||||
}
|
||||
41
app/sitemap.ts
Normal file
41
app/sitemap.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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]
|
||||
}
|
||||
Reference in New Issue
Block a user