import Link from "next/link"; import { getBlogRoute, normalizeTagSlug, type BlogPost } from "@/core/blog"; import { cn } from "@/lib/utils"; type PostListProps = { description?: string; posts: BlogPost[]; title: string; }; type PostMetaProps = { currentLang?: string; date?: string | null; languages?: string[]; pathname?: string; }; function formatDate(date?: string): string | null { if (!date) { return null; } const value = new Date(date); if (Number.isNaN(value.getTime())) { return date; } return new Intl.DateTimeFormat("en-US", { day: "numeric", month: "short", year: "numeric", }).format(value); } export function PostMeta({ currentLang, date, languages, pathname, }: PostMetaProps) { const formattedDate = formatDate(date ?? undefined); const availableLanguages = Array.isArray(languages) ? languages.filter((lang): lang is string => typeof lang === "string") : []; if (!formattedDate && availableLanguages.length <= 1) { return null; } return (
{formattedDate ? (

{formattedDate}

) : null} {pathname && availableLanguages.length > 1 ? (
Language: {availableLanguages.map((lang) => { const isActive = lang === currentLang; return ( {lang.toUpperCase()} ); })}
) : null}
); } export function PostTags({ tags, className, }: { tags?: unknown; className?: string; }) { if (!Array.isArray(tags)) { return null; } const validTags = tags.filter( (tag): tag is string => typeof tag === "string" && tag.length > 0, ); if (validTags.length === 0) { return null; } return (
Tags: {validTags.map((tag) => ( {tag} ))}
); } export function PostList({ description, posts, title }: PostListProps) { return (

{title}

{description ? (

{description}

) : null}
{posts.map((post) => { return (
{post.title}
{post.metadata.description ? (

{post.metadata.description}

) : null}
); })}
); }