From cbfb4c667c93a2f2f779c40f3b7ec3e5ba8f3df8 Mon Sep 17 00:00:00 2001 From: rattatwinko Date: Tue, 17 Jun 2025 12:42:59 +0200 Subject: [PATCH] Refactor layout.tsx to include new header buttons and SVG icons for improved UI --- src/app/AboutButton.tsx | 20 +++++++++++++ src/app/BadgeButton.tsx | 31 ++++++++++++++++++++ src/app/HeaderButtons.tsx | 37 ++++++++++++++++++++++++ src/app/layout.tsx | 24 ++++++++++++++-- src/app/page.tsx | 59 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 168 insertions(+), 3 deletions(-) create mode 100644 src/app/AboutButton.tsx create mode 100644 src/app/BadgeButton.tsx create mode 100644 src/app/HeaderButtons.tsx diff --git a/src/app/AboutButton.tsx b/src/app/AboutButton.tsx new file mode 100644 index 0000000..b4832ac --- /dev/null +++ b/src/app/AboutButton.tsx @@ -0,0 +1,20 @@ +'use client'; +import BadgeButton from './BadgeButton'; + +const InfoIcon = ( + +); + +export default function AboutButton() { + return ( + window.open('http://' + window.location.hostname + ':80', '_blank')} + /> + ); +} diff --git a/src/app/BadgeButton.tsx b/src/app/BadgeButton.tsx new file mode 100644 index 0000000..a8330cd --- /dev/null +++ b/src/app/BadgeButton.tsx @@ -0,0 +1,31 @@ +"use client"; +import React from 'react'; + +export default function BadgeButton({ + label, + color = '#2563eb', + icon, + onClick, +}: { + label: string; + color?: string; + icon: React.ReactNode; + onClick?: () => void; +}) { + return ( + + ); +} \ No newline at end of file diff --git a/src/app/HeaderButtons.tsx b/src/app/HeaderButtons.tsx new file mode 100644 index 0000000..61747b6 --- /dev/null +++ b/src/app/HeaderButtons.tsx @@ -0,0 +1,37 @@ +'use client'; +import BadgeButton from './BadgeButton'; +import AboutButton from './AboutButton'; + +const PersonIcon = ( + + + + +); + +const InfoIcon = ( + + + + + +); + +export default function HeaderButtons() { + return ( +
+ window.location.href = '/admin'} + /> + window.open('http://' + window.location.hostname + ':80', '_blank')} + /> +
+ ); +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 35b3a16..b6e0386 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,6 +3,9 @@ import { Inter } from 'next/font/google'; import './globals.css'; import Link from 'next/link'; import Head from 'next/head'; +import AboutButton from './AboutButton'; +import BadgeButton from './BadgeButton'; +import HeaderButtons from './HeaderButtons'; const inter = Inter({ subsets: ['latin'] }); @@ -11,6 +14,21 @@ export const metadata: Metadata = { description: 'Ein Blog von Sebastian Zinkl, gebaut mit Next.js und Markdown', }; +const PersonIcon = ( + + + + +); + +const InfoIcon = ( + + + + + +); + export default function RootLayout({ children, }: { @@ -42,9 +60,9 @@ export default function RootLayout({ GitHub - - Admin Login - +
+ +
{children} diff --git a/src/app/page.tsx b/src/app/page.tsx index 3543d4b..fa122a6 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -72,6 +72,19 @@ export default function Home() { })), ]; + // Helper to recursively collect all posts from the tree + function collectPosts(nodes: Node[]): Post[] { + let posts: Post[] = []; + for (const node of nodes) { + if (node.type === 'post') { + posts.push(node); + } else if (node.type === 'folder') { + posts = posts.concat(collectPosts(node.children)); + } + } + return posts; + } + return (

Sebastian Zinkls - Blog

@@ -89,6 +102,52 @@ export default function Home() { ))} + {/* Pinned posts at the top (only on root) */} + {currentPath.length === 0 && (() => { + const allPosts = collectPosts(tree); + const pinnedPosts = allPosts.filter((post) => post.pinned); + if (pinnedPosts.length === 0) return null; + return ( +
+

📌 Pinned Posts

+
+ {pinnedPosts.map((post) => ( +
+ 📌 + +

{post.title}

+
+ {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) => ( + + {tag} + + ))} +
+ +
+ ))} +
+
+ ); + })()}
{/* Folders */} {nodes.filter((n) => n.type === 'folder').map((folder: any) => (