#!/usr/bin/env node const fs = require('fs') const path = require('path') // Paths const peopleImagesDir = path.join(__dirname, '../public/images/people') const peopleComponentsDir = path.join(__dirname, '../src/components/people') const peopleAppDir = path.join(__dirname, '../src/app/people') // Function to parse markdown frontmatter function parseFrontmatter(content) { const frontmatterRegex = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/ const match = content.match(frontmatterRegex) if (!match) return null const frontmatter = {} const body = match[2].trim() // Parse YAML-like frontmatter const lines = match[1].split('\n') let currentKey = null for (const line of lines) { const trimmed = line.trim() if (!trimmed) continue if (trimmed.includes(':') && !trimmed.startsWith(' ')) { const [key, ...valueParts] = trimmed.split(':') const value = valueParts.join(':').trim() currentKey = key.trim() if (value) { if (value.startsWith('[') && value.endsWith(']')) { // Array value frontmatter[currentKey] = value.slice(1, -1).split(',').map(v => v.trim()) } else if (value.startsWith('{') && value.endsWith('}')) { // Object value - parse simple key-value pairs const obj = {} const objContent = value.slice(1, -1) const pairs = objContent.split(',') for (const pair of pairs) { const [k, v] = pair.split(':').map(s => s.trim()) if (k && v) { obj[k] = v } } frontmatter[currentKey] = obj } else { frontmatter[currentKey] = value } } } } return { frontmatter, body } } // Function to convert name to component name function nameToComponentName(name) { return name.replace(/\s+/g, '_').replace(/[^a-zA-Z0-9_]/g, '') } // Function to convert name to function name function nameToFunctionName(name) { return 'People_' + nameToComponentName(name) } // Function to generate people component function generatePeopleComponent(personData) { const { name, role, imageUrl, linkedinUrl, description } = personData const functionName = nameToFunctionName(name) return `import { PersonTemplate } from '@/components/PersonTemplate' export const data = [ { name: '${name}', role: '${role}', imageUrl: '${imageUrl}', xUrl: '#', linkedinUrl: '${linkedinUrl || '#'}', }, ] const biography = \`

${description || `${name} is a valued member of our team, bringing expertise and dedication to their role as ${role}.`}

\` export function ${functionName}() { return } ` } // Function to generate page component function generatePageComponent(personData) { const { name } = personData const functionName = nameToFunctionName(name) const componentName = nameToComponentName(name) const pageFunctionName = name.replace(/\s+/g, '') + 'Page' return `import { CallToAction } from '@/components/CallToAction' import { Faqs } from '@/components/Faqs' import { Footer } from '@/components/Footer' import { Header_darkbg } from '@/components/Header_darkbg' import { ${functionName} } from '@/components/people/People_${componentName}' export default function ${pageFunctionName}() { return ( <>
<${functionName} />