Skip to main content
Glama
mednabouli

MCP Multi-Context Hook Generator

by mednabouli
page.ts1.19 kB
import fs from 'fs'; import path from 'path'; export function generatePage(rootPath: string, pageName: string, components: string[] = []) { const pagesDir = path.join(rootPath, 'app', pageName.toLowerCase()); if (!fs.existsSync(pagesDir)) fs.mkdirSync(pagesDir, { recursive: true }); const imports = components.map((c) => `import ${c} from "../../components/${c}";`).join('\n'); const jsxComponents = components.map((c) => `<${c} />`).join('\n '); const code = ` ${imports} export default function ${pageName}Page() { return ( <div> ${jsxComponents} </div> ); } `; const filePath = path.join(pagesDir, 'page.tsx'); fs.writeFileSync(filePath, code); return filePath; } // Example usage: // generatePage("/path/to/project", "Home", ["Header", "Footer"]); // This will create a file at /path/to/project/app/home/page.tsx // with imports for Header and Footer components. // The generated file will look like this: // import Header from "../../components/Header"; // import Footer from "../../components/Footer"; // // export default function HomePage() { // return ( // <div> // <Header /> // <Footer /> // </div> // ); // }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mednabouli/MCPV2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server