📄 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',
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user