From 13c841adb805fc91625bbcc7a78d9a57d665d8a7 Mon Sep 17 00:00:00 2001 From: rattatwinko Date: Wed, 18 Jun 2025 23:04:09 +0200 Subject: [PATCH] Refactor Home component to display blog owner's name dynamically; add folder path display for posts and improve post rendering logic for better clarity and organization. --- src/app/page.tsx | 92 ++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 68dc616..5fb6a2c 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'; import Link from 'next/link'; import { format } from 'date-fns'; +import React from 'react'; interface Post { type: 'post'; @@ -30,6 +31,9 @@ export default function Home() { const [currentPath, setCurrentPath] = useState([]); const [search, setSearch] = useState(''); + // Get blog owner from env + const blogOwner = process.env.NEXT_PUBLIC_BLOG_OWNER || 'Anonymous'; + useEffect(() => { loadTree(); const interval = setInterval(loadTree, 500); @@ -100,7 +104,7 @@ export default function Home() { return (
-

Willkommen auf dem Blog!

+

{blogOwner}'s Blog

Keine Beiträge gefunden.
; } - return posts.map((post: any) => ( -
- {post.pinned && ( - 📌 - )} - -

{post.title}

-
- {post.date ? ( -
Veröffentlicht: {format(new Date(post.date), 'd. MMMM yyyy')}
- ) : ( -
-
- ⚙️ - ⚙️ -
-
In Bearbeitung
-
+ return posts.map((post: any) => { + // Determine folder path from slug + let folderPath = ''; + if (post.slug.includes('/')) { + folderPath = post.slug.split('/').slice(0, -1).join('/'); + } + return ( +
+ {post.pinned && ( + 📌 + )} + +

{post.title}

+ {folderPath && ( +
in {folderPath}
)} -
Erstellt: {format(new Date(post.createdAt), 'd. MMMM yyyy HH:mm')}
-
-

{post.summary}

-
- {post.tags.map((tag: string) => { - const q = search.trim().toLowerCase(); - const isMatch = q && tag.toLowerCase().includes(q); - return ( - - {tag} - - ); - })} -
- -
- )); +
+ {post.date ? ( +
Veröffentlicht: {format(new Date(post.date), 'd. MMMM yyyy')}
+ ) : ( +
+
+ ⚙️ + ⚙️ +
+
In Bearbeitung
+
+ )} +
Erstellt: {format(new Date(post.createdAt), 'd. MMMM yyyy HH:mm')}
+
+

{post.summary}

+
+ {post.tags.map((tag: string) => { + const q = search.trim().toLowerCase(); + const isMatch = q && tag.toLowerCase().includes(q); + return ( + + {tag} + + ); + })} +
+ + + ); + }); })()}