import { Download } from "lucide-react"; import fs from "fs"; import path from "path"; export default function AVB() { const filePath = path.join(process.cwd(), "context/avbs.md"); const fileContent = fs.readFileSync(filePath, "utf8"); // Split by double newlines to get major blocks const rawBlocks = fileContent .split(/\n\s*\n/) .map((b) => b.trim()) .filter((b) => b !== ""); const title = rawBlocks[0]?.replace(/^#\s+/, "") || "Allgemeine Verkaufsbedingungen"; const stand = rawBlocks[1] || "Stand: April 2026"; const sections: { title: string; content: string[] }[] = []; let currentSection: { title: string; content: string[] } | null = null; // Skip title and stand rawBlocks.slice(2).forEach((block) => { if (block.startsWith("##")) { // New section header: e.g. "## 1. Geltungsbereich" if (currentSection) sections.push(currentSection); currentSection = { title: block.replace(/^##\s+/, "").trim(), content: [] }; } else if (currentSection) { // Content block: might be multiple paragraphs if not split by double newline, // but here each block is one "paragraph" due to our split logic. // We clean up bold markers for better display if they are just numbering. const cleanedBlock = block.replace(/\*\*(.*?)\*\*/g, "$1"); currentSection.content.push(cleanedBlock); } }); if (currentSection) sections.push(currentSection); // The very last block might be a footer/schlussbestimmung if it's not in a section // In our MD, everything is in a section, so we just use the last block of the last section as potential footer if we want, // but the current UI expects a separate 'footer' variable. const footer = "MB Grid Solutions & Services"; return (

{title}

{stand}

Als PDF herunterladen
{sections.map((section, index) => (

{section.title}

{section.content.map((paragraph, pIndex) => (

{paragraph.split(/(\[.*?\]\(.*?\))/g).map((part, i) => { const match = part.match(/\[(.*?)\]\((.*?)\)/); if (match) { return ( {match[1]} ); } return part; })}

))}
))}

{footer}

); }