From 3a7cb097dfcf0672204fff2a3409a1817a87e5fa Mon Sep 17 00:00:00 2001
From: schererleander <leander@schererleander.de>
Date: Wed, 25 Jun 2025 01:28:12 +0200
Subject: swap gray-matter for vite-plugin-markdown

---
 src/pages/Blog.tsx | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

(limited to 'src/pages/Blog.tsx')

diff --git a/src/pages/Blog.tsx b/src/pages/Blog.tsx
index 5db87c8..fa9b609 100644
--- a/src/pages/Blog.tsx
+++ b/src/pages/Blog.tsx
@@ -1,5 +1,3 @@
-import { useMemo } from "react";
-import matter from "gray-matter";
 import { Link } from "react-router-dom";
 import CardLink from "../components/CardLink";
 
@@ -11,40 +9,36 @@ interface PostMeta {
   cover?: string;
 }
 
-export default function Blog() {
-  const posts = useMemo<PostMeta[]>(() => {
-    const files = import.meta.glob("../blog/*.md", {
-      eager: true,
-      query: "?raw",
-      import: "default",
-    }) as Record<string, string>;
+const postFiles = import.meta.glob("../blog/*.md", { eager: true }) as Record<
+  string,
+  { attributes: Omit<PostMeta, "slug"> }
+>;
 
-    return Object.entries(files)
-      .map(([path, raw]) => {
-        const { data } = matter(raw);
-        const slug = path.split("/").pop()!.replace(".md", "");
-        return { slug, ...data } as PostMeta;
-      })
-      .sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
-  }, []);
+const posts: PostMeta[] = Object.entries(postFiles)
+  .map(([path, mod]) => ({
+    slug: path.split("/").pop()!.replace(".md", ""),
+    ...(mod.attributes as Omit<PostMeta, "slug">),
+  }))
+  .sort(
+    (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
+  );
 
+export default function Blog() {
   return (
     <section className="container mx-auto px-4 py-10">
       <h1 className="text-4xl font-bold mb-8">Blog</h1>
 
       <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
         {posts.map((post) => (
-          /* 1) Link für internes Routing                              */
-          /* 2) CardLink bekommt genau deine Prop-Namen                */
           <Link key={post.slug} to={`/blog/${post.slug}`} className="block">
             <CardLink
               title={post.title}
-              body={post.excerpt}  // <—  body statt description
-              imgSrc={post.cover}  // <—  imgSrc statt image
+              body={post.excerpt}
+              imgSrc={post.cover}
             />
           </Link>
         ))}
       </div>
     </section>
   );
-}
+}
\ No newline at end of file
-- 
cgit v1.3.1

