-
-
- {
- posts
- .slice(0, 3)
- .sort(
- (a, b) => /* This is reversed because we want the latest post on top */
- Date.parse(b.frontmatter.date) - Date.parse(a.frontmatter.date)
- )
- .map((post) => (
-
- ))
- }
-
+
+
+
Blog posts
+
+
+
+ {
+ publishedBlogPosts.map((post) => {
+ console.log("hello")
+ return (
+
+ );
+ })
+ }
-
-
diff --git a/src/pages/blog.astro b/src/pages/blog.astro
index 3f5fcab..a637a3d 100644
--- a/src/pages/blog.astro
+++ b/src/pages/blog.astro
@@ -1,42 +1,34 @@
---
-import BlogPostCard from "../components/card/BlogPostCard.astro";
+import NEWBlogPostCard from "../components/card/NEWBlogPostCard.astro";
import BaseLayout from "../layouts/BaseLayout.astro";
-interface Frontmatter {
- title: string;
- slug: string;
- thumbnail: string;
- date: string;
- description: string;
- author: string;
-}
-
-const posts = await Astro.glob
("./posts/*.md");
+import { getCollection } from "astro:content";
+const publishedBlogPosts = await getCollection("blog", ({ data }) => {
+ return data.draft !== true;
+});
---
-
+
Blog posts
-
+
{
- posts
- .sort(
- (a, b) => /* This is reversed because we want the latest post on top */
- Date.parse(b.frontmatter.date) - Date.parse(a.frontmatter.date)
- )
- .map((post) => (
-
- ))
+ publishedBlogPosts.map((post) => (
+
+ ))
}