import React from 'react'; import { Heading } from '@/components/ui'; import fs from 'fs/promises'; import path from 'path'; import matter from 'gray-matter'; export const AgbHistoryBlock: React.FC<{ title: string }> = async ({ title }) => { const agbs: any[] = []; try { const dir = path.join(process.cwd(), 'content', 'agbs'); const files = await fs.readdir(dir); for (const f of files) { if (!f.endsWith('.mdx')) continue; const fileContent = await fs.readFile(path.join(dir, f), 'utf-8'); const { data } = matter(fileContent); agbs.push({ id: f, ...data }); } agbs.sort( (a, b) => new Date(b.versionDate || 0).getTime() - new Date(a.versionDate || 0).getTime(), ); } catch (err) { console.error('Failed reading AGBs from MDX:', err); } if (agbs.length === 0) { return null; } return (