|
|
|
|
@@ -6,61 +6,42 @@ 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 (headers + their first paragraphs, or subsequent paragraphs)
|
|
|
|
|
const blocks = fileContent
|
|
|
|
|
// Split by double newlines to get major blocks
|
|
|
|
|
const rawBlocks = fileContent
|
|
|
|
|
.split(/\n\s*\n/)
|
|
|
|
|
.map((b) => b.trim())
|
|
|
|
|
.filter((b) => b !== "");
|
|
|
|
|
|
|
|
|
|
const title = blocks[0] || "Liefer- und Zahlungsbedingungen";
|
|
|
|
|
const stand = blocks[1] || "Stand Januar 2026";
|
|
|
|
|
// Extract title and stand more robustly
|
|
|
|
|
const title = rawBlocks.find(b => b.startsWith("# "))?.replace(/^#\s+/, "") || "Allgemeine Verkaufsbedingungen";
|
|
|
|
|
const stand = rawBlocks.find(b => b.toLowerCase().startsWith("stand:")) || "Stand: April 2026";
|
|
|
|
|
|
|
|
|
|
const sections: { title: string; content: string[] }[] = [];
|
|
|
|
|
let currentSection: { title: string; content: string[] } | null = null;
|
|
|
|
|
|
|
|
|
|
// Skip title and stand
|
|
|
|
|
blocks.slice(2).forEach((block) => {
|
|
|
|
|
const lines = block
|
|
|
|
|
.split("\n")
|
|
|
|
|
.map((l) => l.trim())
|
|
|
|
|
.filter((l) => l !== "");
|
|
|
|
|
if (lines.length === 0) return;
|
|
|
|
|
// Process sections, skipping title and stand blocks
|
|
|
|
|
rawBlocks.forEach((block) => {
|
|
|
|
|
if (block.startsWith("# ") || block.toLowerCase().startsWith("stand:")) return;
|
|
|
|
|
|
|
|
|
|
const firstLine = lines[0];
|
|
|
|
|
|
|
|
|
|
if (/^\d+\./.test(firstLine)) {
|
|
|
|
|
// New section
|
|
|
|
|
if (block.startsWith("##")) {
|
|
|
|
|
// New section header: e.g. "## 1. Geltungsbereich"
|
|
|
|
|
if (currentSection) sections.push(currentSection);
|
|
|
|
|
|
|
|
|
|
currentSection = { title: firstLine, content: [] };
|
|
|
|
|
|
|
|
|
|
// If there are more lines in this block, they form the first paragraph(s)
|
|
|
|
|
if (lines.length > 1) {
|
|
|
|
|
// Join subsequent lines as they might be part of the same paragraph
|
|
|
|
|
// In this MD, we'll assume lines in the same block belong together
|
|
|
|
|
// unless they are clearly separate paragraphs (but we already split by double newline)
|
|
|
|
|
const remainingText = lines.slice(1).join(" ");
|
|
|
|
|
if (remainingText) currentSection.content.push(remainingText);
|
|
|
|
|
}
|
|
|
|
|
currentSection = {
|
|
|
|
|
title: block.replace(/^##\s+/, "").trim(),
|
|
|
|
|
content: []
|
|
|
|
|
};
|
|
|
|
|
} else if (currentSection) {
|
|
|
|
|
// Continuation of current section
|
|
|
|
|
const blockText = lines.join(" ");
|
|
|
|
|
if (blockText) currentSection.content.push(blockText);
|
|
|
|
|
// Clean up bold markers for better display
|
|
|
|
|
const cleanedBlock = block.replace(/\*\*(.*?)\*\*/g, "$1");
|
|
|
|
|
currentSection.content.push(cleanedBlock);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (currentSection) sections.push(currentSection);
|
|
|
|
|
|
|
|
|
|
// The last block is the footer
|
|
|
|
|
const footer = blocks[blocks.length - 1];
|
|
|
|
|
if (sections.length > 0) {
|
|
|
|
|
const lastSection = sections[sections.length - 1];
|
|
|
|
|
if (lastSection.content.includes(footer) || lastSection.title === footer) {
|
|
|
|
|
lastSection.content = lastSection.content.filter((c) => c !== footer);
|
|
|
|
|
if (sections[sections.length - 1].title === footer) {
|
|
|
|
|
sections.pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 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 (
|
|
|
|
|
<div className="bg-slate-50 min-h-screen pt-40 pb-20">
|
|
|
|
|
@@ -114,8 +95,9 @@ export default function AVB() {
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
<div className="pt-8 border-t border-slate-100">
|
|
|
|
|
<p className="font-bold text-primary">{footer}</p>
|
|
|
|
|
<div className="pt-8 border-t border-slate-100 flex justify-between items-center text-slate-400 text-sm italic">
|
|
|
|
|
<p>{footer}</p>
|
|
|
|
|
<p>{stand}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|