import React from 'react'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; import Paper from '@mui/material/Paper'; import LegalPage from './pages/LegalPage.js'; import CategoryBox from './components/CategoryBox.js'; const PrerenderCategoriesPage = ({ categoryData }) => { // Helper function to recursively collect all categories from the tree const collectAllCategories = (categoryNode, categories = [], level = 0) => { if (!categoryNode) return categories; // Add current category (skip root category 209) if (categoryNode.id !== 209 && categoryNode.seoName) { categories.push({ id: categoryNode.id, name: categoryNode.name, seoName: categoryNode.seoName, level: level }); } // Recursively add children if (categoryNode.children) { for (const child of categoryNode.children) { collectAllCategories(child, categories, level + 1); } } return categories; }; // The categoryData passed prop is the root tree (id: 209) const rootTree = categoryData; const renderLevel1Section = (l1Node) => { // Collect all descendants (excluding the L1 node itself, which collectAllCategories would include first) const descendants = collectAllCategories(l1Node).slice(1); return ( {/* Level 1 Header/Box */} {/* Descendants area */} {descendants.map((cat) => ( ))} ); }; const content = ( {rootTree && rootTree.children && rootTree.children.map((child) => ( renderLevel1Section(child) ))} {(!rootTree || !rootTree.children || rootTree.children.length === 0) && ( Keine Kategorien gefunden. )} ); return ; }; export default PrerenderCategoriesPage;