diff --git a/src/components/helper/authors/Info.astro b/src/components/helper/authors/Info.astro index 806a143..ed37cb0 100644 --- a/src/components/helper/authors/Info.astro +++ b/src/components/helper/authors/Info.astro @@ -3,14 +3,13 @@ import {Image} from "astro:assets"; import {getEntry} from "astro:content"; import {siteConfig} from "../../../config"; -const { id } = Astro.props; +const { data } = Astro.props; // Get author data -const authorData = await getEntry('authors', id || ''); -const authorAvatar = authorData?.data.mcplayerid ? `/images/avatars/${id}.png` : null; -const authorName = authorData ? authorData.data.name : null; +const authorAvatar = data?.data.mcplayerid ? `/images/avatars/${data.id}.png` : null; +const authorName = data ? data.data.name : null; --- -{(siteConfig.displayAvatar && authorData) && +{(siteConfig.displayAvatar && data) && <> {authorAvatar && {`avatar} {authorName} @ diff --git a/src/content/posts/_schemas.ts b/src/content/posts/_schemas.ts index 2a535ff..daf11e5 100644 --- a/src/content/posts/_schemas.ts +++ b/src/content/posts/_schemas.ts @@ -1,4 +1,4 @@ -import { z } from 'astro:content'; +import { z, reference } from 'astro:content'; export const posts = ({ image }) => z.object({ title: z.string(), @@ -8,5 +8,5 @@ export const posts = ({ image }) => z.object({ categories: z.array(z.string()).default(['uncategorized']), tags: z.array(z.string()).optional(), cover: image().optional(), - author: z.string().optional(), + author: reference('authors').optional(), }); \ No newline at end of file diff --git a/src/pages/post/[...slug].astro b/src/pages/post/[...slug].astro index 886f4b2..da2b02a 100644 --- a/src/pages/post/[...slug].astro +++ b/src/pages/post/[...slug].astro @@ -19,10 +19,10 @@ const { entry } = Astro.props; const { Content } = await entry.render(); const noscript = siteConfig.noClientJavaScript const slug = Astro.params.slug; -const authorId = entry.data.author || siteConfig.defaultAuthor.id; +const author = entry.data.author || {collection: 'authors', id: siteConfig.defaultAuthor.id}; // Get author data -const authorData = await getEntry('authors', authorId); +const authorData = await getEntry(author); const authorInfo = authorData ? authorData.data : siteConfig.defaultAuthor; // get featured image and use it as og:image @@ -46,7 +46,7 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || ` author={authorInfo.name} >

{entry.data.title}

- + {new Date(entry.data.pubDate).toISOString().split('T')[0]}
@@ -59,4 +59,5 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || ` {noscript &&

Comments

}
- \ No newline at end of file + + diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index c3ba18d..bdef740 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -52,7 +52,16 @@ export async function GET(context) { }, sanitize({ dropElements: ["script", "style"] }), ]); - feedItems.push({ ...post.data, link: `/post/${post.slug}/`, content }); + + // Make sure each feed item has required properties with proper formatting + feedItems.push({ + title: post.data.title, + description: post.data.description || '', + pubDate: post.data.pubDate, + link: `${baseUrl}/post/${post.slug}`, + content, + }); + } // Return our RSS feed XML response.