This commit is contained in:
Timo Knuth 2026-01-26 19:51:00 +01:00
parent 7b2788da7a
commit 76a76258e8
7 changed files with 378 additions and 333 deletions

41
scripts/validate-data.ts Normal file
View File

@ -0,0 +1,41 @@
import { blogPosts } from '../src/lib/blog-data';
import { authors } from '../src/lib/author-data';
import { getPublishedPosts, getPostsByAuthor } from '../src/lib/content';
console.log("Validating Author Data...");
authors.forEach(author => {
console.log(`Checking author: ${author.slug}`);
if (!author.name) console.error(`Error: Author ${author.slug} missing name`);
if (!author.image) console.warn(`Warning: Author ${author.slug} missing image`);
});
console.log("\nValidating Blog Data...");
blogPosts.forEach(post => {
try {
if (!post.slug) console.error("Error: Post missing slug", post);
if (!post.datePublished && !post.date) console.error(`Error: Post ${post.slug} missing date`);
const d = new Date(post.datePublished || post.date);
if (isNaN(d.getTime())) {
console.error(`Error: Post ${post.slug} has invalid date: ${post.datePublished || post.date}`);
}
} catch (e) {
console.error(`Exception checking post ${post.slug || 'unknown'}:`, e);
}
});
console.log("\nTesting Content Functions...");
try {
const published = getPublishedPosts();
console.log(`getPublishedPosts returned ${published.length} posts.`);
authors.forEach(author => {
const posts = getPostsByAuthor(author.slug);
console.log(`Author ${author.slug} has ${posts.length} posts.`);
});
} catch (e) {
console.error("Error running content functions:", e);
}
console.log("\nValidation Complete.");

View File

@ -81,7 +81,7 @@ export default function AuthorPage({ params }: { params: { slug: string } }) {
<div className="space-y-4">
{posts.map(p => (
<Link key={p.slug} href={`/blog/${p.slug}`} className="block group p-6 rounded-xl border border-gray-200 bg-white hover:border-blue-200 hover:shadow-sm transition-all">
<div className="text-sm text-gray-400 mb-1">{p.date}</div>
<div className="text-sm text-gray-400 mb-1">{new Date(p.datePublished || p.date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}</div>
<h3 className="text-xl font-bold text-gray-900 group-hover:text-blue-700 transition-colors mb-2">{p.title}</h3>
<p className="text-gray-600">{p.description}</p>
</Link>

View File

@ -55,7 +55,7 @@ export default function PillarPage({ params }: { params: { pillar: PillarKey } }
<div className="grid md:grid-cols-2 gap-6">
{posts.map(p => (
<Link key={p.slug} href={`/blog/${p.slug}`} className="group block rounded-xl border border-gray-200 bg-white p-6 shadow-sm hover:shadow-md hover:border-blue-200 transition-all">
<div className="text-xs text-gray-400 mb-2">{p.date}</div>
<div className="text-xs text-gray-400 mb-2">{new Date(p.datePublished || p.date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}</div>
<div className="text-lg font-bold text-gray-900 mb-2 group-hover:text-blue-700">{p.title}</div>
<div className="text-sm text-gray-600 line-clamp-2">{p.description}</div>
</Link>

View File

@ -10,7 +10,11 @@ export const metadata = {
export default function LearnHubPage() {
const posts = getPublishedPosts();
// Sort by date descending
const topLatest = [...posts].sort((a, b) => (new Date(a.datePublished).getTime() < new Date(b.datePublished).getTime() ? 1 : -1)).slice(0, 6);
const topLatest = [...posts].sort((a, b) => {
const dateA = a.datePublished ? new Date(a.datePublished) : new Date(a.date);
const dateB = b.datePublished ? new Date(b.datePublished) : new Date(b.date);
return dateB.getTime() - dateA.getTime();
}).slice(0, 6);
return (
<main className="container mx-auto max-w-5xl py-12 px-4 space-y-12">
@ -41,7 +45,7 @@ export default function LearnHubPage() {
<Link key={p.slug} href={`/blog/${p.slug}`} className="group block rounded-2xl border border-gray-200 bg-white p-6 shadow-sm hover:shadow-md hover:border-blue-200 transition-all">
<div className="flex justify-between items-center mb-3">
<div className="text-xs font-semibold px-2 py-1 rounded bg-gray-100 text-gray-600">{p.pillar?.toUpperCase() || 'GUIDE'}</div>
<div className="text-xs text-gray-400">{p.date}</div>
<div className="text-xs text-gray-400">{new Date(p.datePublished || p.date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}</div>
</div>
<div className="text-xl font-bold text-gray-900 mb-2 group-hover:text-blue-700 line-clamp-2">{p.title}</div>
<div className="text-gray-600 line-clamp-2">{p.description}</div>