<?php
/**
 * Vue : portail de documentation (/doc).
 * @var array<string, list<array{slug:string,title:string}>> $groups
 */

$pageTitle = t('doc.title');
include WEBROOT_PATH . '/includes/header.php';

$hasAny = false;
foreach ($groups as $docs) {
    if (!empty($docs)) { $hasAny = true; break; }
}
?>

<div class="page-header">
    <h1><?= t('doc.title') ?></h1>
</div>

<?php if (!$hasAny): ?>
    <div class="card"><p><?= t('doc.empty') ?></p></div>
<?php else: ?>
    <?php foreach (DocCatalog::GROUPS as $group): ?>
        <?php if (empty($groups[$group])) continue; ?>
        <div class="card" style="margin-bottom:1.2rem">
            <h2 style="font-size:1rem;margin:0 0 .6rem"><?= t('doc.cat_' . $group) ?></h2>
            <ul class="doc-list" style="margin:0;padding-left:1.2rem;line-height:1.9">
                <?php foreach ($groups[$group] as $doc): ?>
                    <li>
                        <a href="/doc/<?= htmlspecialchars(rawurlencode($doc['slug'])) ?>">
                            <?= htmlspecialchars($doc['title']) ?>
                        </a>
                    </li>
                <?php endforeach; ?>
            </ul>
        </div>
    <?php endforeach; ?>
<?php endif; ?>

<?php include WEBROOT_PATH . '/includes/footer.php'; ?>
