diff --git a/src/components/ArticleList.astro b/src/components/ArticleList.astro index 698b205..f67a2ae 100644 --- a/src/components/ArticleList.astro +++ b/src/components/ArticleList.astro @@ -4,7 +4,7 @@ const { posts, displayDate = false, placeholder = false } = Astro.props;
{posts.map((post) => (

- {displayDate && {new Date(post.data.date).toISOString().split('T')[0]}} + {displayDate && {new Date(post.data.pubDate).toISOString().split('T')[0]}} {post.data.title}

))} diff --git a/src/components/Search.astro b/src/components/Search.astro index f1a288f..838d93e 100644 --- a/src/components/Search.astro +++ b/src/components/Search.astro @@ -75,7 +75,7 @@ const domain = Astro.url.host title: string; description?: string; slug?: string; - date?: Date; + pubDate?: Date; searchableTitle: string; searchableDesc: string; searchableContent: string; @@ -199,7 +199,7 @@ const domain = Astro.url.host
${item.title}
- ${new Date(item.date).toISOString().split('T')[0]|| '' } — + ${new Date(item.pubDate).toISOString().split('T')[0]|| '' } — ${item.description || ''}
diff --git a/src/content/posts/_schemas.ts b/src/content/posts/_schemas.ts index 7408b68..541099f 100644 --- a/src/content/posts/_schemas.ts +++ b/src/content/posts/_schemas.ts @@ -5,7 +5,8 @@ export const posts = ({ image }) => z.object({ title: z.string(), description: z.string(), summary: z.string().optional(), - date: z.coerce.date(), + pubDate: z.coerce.date(), + updatedDate: z.coerce.date().optional(), categories: z.array(z.string()).default(['uncategorized']), tags: z.array(z.string()).optional(), cover: image().optional(), diff --git a/src/content/posts/first-post/index.md b/src/content/posts/first-post/index.md index 7e47cd4..7ef5f97 100644 --- a/src/content/posts/first-post/index.md +++ b/src/content/posts/first-post/index.md @@ -1,7 +1,7 @@ --- title: 'First Post' description: 'Welcome to my terminal blog' -date: '2025-06-01' +pubDate: '2025-06-01' --- Hello world! This is the first post on my new terminal blog. diff --git a/src/content/posts/markdown-example/index.mdx b/src/content/posts/markdown-example/index.mdx index f1e9b63..5319c28 100644 --- a/src/content/posts/markdown-example/index.mdx +++ b/src/content/posts/markdown-example/index.mdx @@ -1,6 +1,6 @@ --- title: "Markdown Syntax Example" -date: '2023-07-15T12:00:00Z' +pubDate: '2023-07-15T12:00:00Z' description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements." tags: ["markdown", "css", "html", "sample"] --- @@ -98,9 +98,9 @@ This most simple one can be used like this: ``` or with a archive link: - + ```mdx - + ``` The `pubDate` or `updatedDate` props is optional, but in order to make the component to display the archived version around the date correctly, they should be passed. diff --git a/src/content/posts/minimalism/index.md b/src/content/posts/minimalism/index.md index 22ea240..cdc32c1 100644 --- a/src/content/posts/minimalism/index.md +++ b/src/content/posts/minimalism/index.md @@ -2,7 +2,7 @@ title: 'The Art of Minimalism' description: 'Thoughts on minimalism in design and code' summary: 'Exploring the principles of minimalism and its application in design and coding practices.' -date: '2025-06-05' +pubDate: '2025-06-05' author: 'Wheatley' tags: - 'design' diff --git a/src/content/posts/terminal-setup/index.md b/src/content/posts/terminal-setup/index.md index 3f481e5..63d8d22 100644 --- a/src/content/posts/terminal-setup/index.md +++ b/src/content/posts/terminal-setup/index.md @@ -1,7 +1,7 @@ --- title: 'My Terminal Setup' description: 'A walkthrough of my current terminal configuration' -date: '2025-06-08' +pubDate: '2025-06-08' author: - 'Glados' - 'Wheatley' diff --git a/src/pages/blog.astro b/src/pages/blog.astro index 3d9cd35..c1d8165 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -10,7 +10,7 @@ const lang = getLangFromUrl(Astro.url); const t = useTranslations(lang); const translatePath = useTranslatedPath(lang); const posts = await getCollection('posts'); -posts.sort((a, b) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime()); +posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime()); --- diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 5a44317..03c3ff8 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -34,7 +34,7 @@ const author = Array.isArray(entry.data.author) ? entry.data.author : (entry.dat const wordcount = remarkPluginFrontmatter.wordcount; const lastUpdated = remarkPluginFrontmatter.lastModified; -const pubDate = new Date(entry.data.date).toISOString().split('T')[0] +const pubDate = new Date(entry.data.pubDate).toISOString().split('T')[0] const lastUpdatedDate = new Date(lastUpdated).toISOString().split('T')[0] // Get author data @@ -65,7 +65,7 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `

{entry.data.title}

{authorInfo.map((a: any) => )} {pubDate} - {new Date(lastUpdated) > new Date(entry.data.date) && ({t('article.last_update')} {lastUpdatedDate})} + {pubDate === lastUpdatedDate && ({t('article.last_update')} {lastUpdatedDate})} | {wordcount.words} {t('article.word_count')} { (cover && cover !== firstImageURL && cover !== `/blog/${slug}/featured.png`) && {`cover } diff --git a/src/pages/blog/[...slug].txt.js b/src/pages/blog/[...slug].txt.js index 6c90c63..8d5624f 100644 --- a/src/pages/blog/[...slug].txt.js +++ b/src/pages/blog/[...slug].txt.js @@ -11,7 +11,7 @@ export async function GET({ props }) { const { entry } = props; // Format the content as plain text const title = entry.data.title; - const date = entry.data.date.toISOString().split('T')[0]; + const date = entry.data.pubDate.toISOString().split('T')[0]; const content = entry.body; // Combine the post info and body into a single text file diff --git a/src/pages/llms.txt.js b/src/pages/llms.txt.js index bdee22c..396352b 100644 --- a/src/pages/llms.txt.js +++ b/src/pages/llms.txt.js @@ -19,10 +19,10 @@ ${await generateMarkdownSection("pages", "Page", baseUrl)}`; async function generateMarkdownSection(collectionName, sectionTitle, baseUrl) { const items = await getCollection(collectionName); - // Sort posts by date if available + // Sort posts by pubDate if available const sortedItems = collectionName === "posts" - ? items.sort((a, b) => (a.data.date > b.data.date ? -1 : 1)) + ? items.sort((a, b) => (a.data.pubDate > b.data.pubDate ? -1 : 1)) : items; let markdown = `## ${sectionTitle}\n`; diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index eb54c16..28a90d4 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -23,7 +23,7 @@ export async function GET(context) { // Load the content collection entries to add to our RSS feed. const posts = (await getCollection("posts")).sort((a, b) => // Sort by publication date descending. - a.data.date > b.data.date ? -1 : 1 + a.data.pubDate > b.data.pubDate ? -1 : 1 ); // Loop over blog posts to create feed items for each, including full content. @@ -57,7 +57,7 @@ export async function GET(context) { feedItems.push({ title: post.data.title, description: post.data.description || '', - date: post.data.date, + pubDate: post.data.pubDate, link: `${baseUrl}/blog/${post.slug}`, content, }); diff --git a/src/pages/search-index.json.js b/src/pages/search-index.json.js index fe24f9f..8b91cef 100644 --- a/src/pages/search-index.json.js +++ b/src/pages/search-index.json.js @@ -6,7 +6,7 @@ export async function GET() { title: post.data.title, description: post.data.description, content: post.body, - date: post.data.date, + pubDate: post.data.pubDate, slug: post.slug })); diff --git a/src/pages/twtxt.txt.js b/src/pages/twtxt.txt.js index 6af2c49..54f6845 100644 --- a/src/pages/twtxt.txt.js +++ b/src/pages/twtxt.txt.js @@ -3,10 +3,10 @@ import { getCollection } from 'astro:content'; export async function GET(context) { const posts = await getCollection('posts'); // Sort posts by date (newest first) - posts.sort((a, b) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime()); + posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime()); const twtxt = posts.map(post => ( - `${new Date(post.data.date).toISOString()}\t${post.data.title} ${context.site}blog/${post.slug}` + `${new Date(post.data.pubDate).toISOString()}\t${post.data.title} ${context.site}blog/${post.slug}` )).join('\n'); return new Response(twtxt, { diff --git a/src/plugins/heatmapdata/local.js b/src/plugins/heatmapdata/local.js index 0c04586..913b059 100644 --- a/src/plugins/heatmapdata/local.js +++ b/src/plugins/heatmapdata/local.js @@ -6,7 +6,7 @@ async function fetchPostsData() { for (const post of posts) { const { remarkPluginFrontmatter } = await post.render(); - const dateKey = post.data.date.toISOString().split('T')[0]; // "2025-07-25" + const dateKey = post.data.pubDate.toISOString().split('T')[0]; // "2025-07-25" entriesData[dateKey] = { wordCount: remarkPluginFrontmatter.wordcount.words / 1000 || 0, link: `/blog/${post.slug}`,