mirror of
https://github.com/mmahdium/portfolio.git
synced 2026-08-16 21:14:31 +03:30
feat(blog): update SEO metadata and improve RSS feed handling for blog posts
This commit is contained in:
@@ -2,14 +2,14 @@ export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig()
|
||||
const siteUrl = config.public.siteUrl || 'https://example.com'
|
||||
|
||||
// Persian locale
|
||||
const locale = 'fa'
|
||||
|
||||
// Fetch published blog posts
|
||||
const posts = await serverQueryContent(event, `${locale}/blog`)
|
||||
.where({ draft: { $ne: true } })
|
||||
.sort({ date: -1 })
|
||||
.find()
|
||||
// In Nitro server routes, `queryCollection` expects the H3 event as the first argument.
|
||||
const allPosts = await queryCollection(event, 'blog').all()
|
||||
|
||||
const posts = allPosts
|
||||
.filter((post: any) => post.path?.startsWith('/fa/blog/') && post.draft !== true)
|
||||
.sort((a: any, b: any) => new Date(b.date).getTime() - new Date(a.date).getTime())
|
||||
|
||||
const escapeXml = (str: string) => {
|
||||
return str
|
||||
@@ -22,7 +22,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const rssItems = posts
|
||||
.map((post) => {
|
||||
const link = `${siteUrl}${post._path}`
|
||||
const link = `${siteUrl}${post.path}`
|
||||
const pubDate = new Date(post.date).toUTCString()
|
||||
|
||||
return `
|
||||
|
||||
Reference in New Issue
Block a user