
const fs = require('fs');

function formatPlants(plants) {
  let md = '# Alle Pflanzen in der Datenbank\n\n';
  md += '| Name | Botanischer Name | Kategorie | Gie├ƒintervall (Tage) | Licht | Temperatur |\n';
  md += '| :--- | :--- | :--- | :--- | :--- | :--- |\n';

  for (const plant of plants) {
    const categories = plant.categories.join(', ');
    const water = plant.careInfo.waterIntervalDays || '-';
    const light = plant.careInfo.light || '-';
    const temp = plant.careInfo.temp || '-';
    md += `| ${plant.name} | *${plant.botanicalName}* | ${categories} | ${water} | ${light} | ${temp} |\n`;
  }

  return md;
}

const plants = JSON.parse(fs.readFileSync('plants_dump_utf8.json', 'utf8'));
const markdown = formatPlants(plants);
fs.writeFileSync('ALLE_PFLANZEN.md', markdown);
console.log('ALLE_PFLANZEN.md created.');
