post sorting and date fixes

This commit is contained in:
2023-01-19 19:02:56 -05:00
parent bcf590e1e2
commit cefcebed6f
5 changed files with 27 additions and 10 deletions
+6 -5
View File
@@ -1,8 +1,13 @@
---
import { formatInTimeZone } from "date-fns-tz";
import Layout from "@layouts/Layout.astro";
import FormattedDate from "@components/FormattedDate.astro";
const posts = await Astro.glob("./posts/*.md");
posts.sort(
(a, b) =>
Date.parse(b.frontmatter.pubDate) - Date.parse(a.frontmatter.pubDate)
);
---
<Layout title="Blog Archive">
@@ -10,11 +15,7 @@ const posts = await Astro.glob("./posts/*.md");
posts.map((post) => (
<div>
<a href={post.url}>{post.frontmatter.title}</a> -{" "}
{formatInTimeZone(
new Date(post.frontmatter.pubDate),
"America/New_York",
"MMM do, y"
)}
<FormattedDate date={post.frontmatter.pubDate} />
</div>
))
}
+5 -1
View File
@@ -5,11 +5,15 @@ import Layout from "@layouts/Layout.astro";
import BlogHeader from "@components/BlogHeader.astro";
const posts = await Astro.glob("./posts/*.md");
posts.sort(
(a, b) =>
Date.parse(b.frontmatter.pubDate) - Date.parse(a.frontmatter.pubDate)
);
---
<Layout title="Home">
{
posts.map((post) => (
posts.slice(0, 5).map((post) => (
<article class="post-preview">
<div>
<BlogHeader
@@ -1,7 +1,7 @@
---
layout: ../../layouts/BlogPost.astro
title: "My Favorite Little Apps"
pubDate: 2022-11-28
title: "Getting Out of Your Comfort Zone"
pubDate: 2022-12-10
---
When it comes to frameworks, Ive been firmly stuck in the Reactand React-adjacentworld. Basically, my “coding comfort zone” has been vanilla JavaScript, React, and Next.js. The world of web development is much broader than that, but Im going to be honest, I was a little scared to branch out.