))
diff --git a/src/pages/blog.astro b/src/pages/blog.astro
index dbd8c5e65..1ed5244de 100644
--- a/src/pages/blog.astro
+++ b/src/pages/blog.astro
@@ -1,62 +1,67 @@
---
+import { getCollection } from "astro:content";
import { Picture } from "@astrojs/image/components";
+import Layout from "@layouts/Layout.astro";
import Container from "@components/container.astro";
import Sectionhead from "@components/sectionhead.astro";
-import Layout from "@layouts/Layout.astro";
-import { getFormattedDate } from "@utils/all";
-import { log } from "astro/dist/core/logger/core";
-// Use Astro.glob() to fetch all posts, and then sort them by date.
-const posts = (await Astro.glob("./blog/*.{md,mdx}")).sort(
- (a, b) =>
- new Date(b.frontmatter.publishDate).valueOf() -
- new Date(a.frontmatter.publishDate).valueOf()
-);
-console.log(posts[0].frontmatter.image);
+// Filter blog entries with 'draft: false' & date before current date
+const publishedBlogEntries = await getCollection("blog", ({ data }) => {
+ return !data.draft && data.publishDate < new Date();
+});
+
+// Sort content entries by publication date
+publishedBlogEntries.sort(function (a, b) {
+ return b.data.publishDate.valueOf() - a.data.publishDate.valueOf();
+});
---
Our Blog
- We write about building startups and thoughts going on our mind.
+
+ We write about building startups and thoughts going on our mind.
+