docs.php1
<?php
$docsDir = __DIR__;
$jsonFile = $docsDir . '/docs.index.json';
echo $jsonFile;
// Load JSON index
$index = json_decode(file_get_contents($jsonFile), true);
$docs = $index['docs'] ?? [];
// Scan for markdown files
$mdFiles = array_filter(scandir($docsDir), fn($f) => pathinfo($f, PATHINFO_EXTENSION) === 'md');
// Build lookup table
$lookup = [];
foreach ($docs as $doc) {
$filename = $doc['filename'];
if (in_array($filename, $mdFiles)) {
$lookup[$doc['group']][] = $doc;
}
}
// Render HTML
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DefApp Documentation</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@4.0.0/dist/css/adminlte.min.css">
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
<section class="content p-4">
<h1 class="mb-4">📚 DefApp Documentation Index</h1>
<?php foreach ($lookup as $group => $items): ?>
<div class="card mb-3">
<div class="card-header bg-primary text-white">
<h3 class="card-title"><?= htmlspecialchars($group) ?></h3>
</div>
<div class="card-body">
<ul class="list-group">
<?php foreach ($items as $doc): ?>
<li class="list-group-item">
<strong><?= htmlspecialchars($doc['short_name']) ?></strong><br>
<small><?= htmlspecialchars($doc['purpose']) ?></small><br>
<a href="<?= htmlspecialchars($doc['filename']) ?>" target="_blank">Open file</a>
<span class="float-end text-muted">
Updated: <?= htmlspecialchars($doc['date_updated']) ?>
</span>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endforeach; ?>
</section>
</div>
</body>
</html>