Merge origin/master

This commit is contained in:
2026-01-25 19:39:57 +01:00
374 changed files with 68385 additions and 36750 deletions
+26 -6
View File
@@ -5,6 +5,7 @@
import fs from 'fs';
import path from 'path';
import { cache } from '@/utils/cache';
/**
* Blog Post Interface
@@ -170,6 +171,14 @@ function parseMarkdownPost(filename: string, content: string): BlogPost | null {
* @returns Array aller Blog-Posts
*/
export function getAllBlogPosts(): BlogPost[] {
const cacheKey = 'blog:all-posts';
// Check cache first
const cachedPosts = cache.get<BlogPost[]>(cacheKey);
if (cachedPosts) {
return cachedPosts;
}
if (!fs.existsSync(BLOG_POSTS_DIR)) {
console.warn('Blog posts directory not found:', BLOG_POSTS_DIR);
return [];
@@ -182,16 +191,27 @@ export function getAllBlogPosts(): BlogPost[] {
const posts: BlogPost[] = [];
for (const file of files) {
const filePath = path.join(BLOG_POSTS_DIR, file);
const content = fs.readFileSync(filePath, 'utf-8');
const post = parseMarkdownPost(file, content);
if (post) {
posts.push(post);
try {
const filePath = path.join(BLOG_POSTS_DIR, file);
const content = fs.readFileSync(filePath, 'utf-8');
const post = parseMarkdownPost(file, content);
if (post) {
posts.push(post);
}
} catch (error) {
// Skip files that fail to parse
console.warn(`Failed to parse blog post: ${file}`, error);
continue;
}
}
// Sort by date descending (newest first)
return posts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
const sortedPosts = posts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
// Cache the results
cache.set(cacheKey, sortedPosts);
return sortedPosts;
}
/**