code.pablomurad.com

indiecheck

Lists the microformats, rel links and IndieWeb endpoints on a page, and how to fix them

views/nav.php raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

use function Indiechecker\e;

$total = count($report->microformats->all);
$checks = $report->indieWeb();
$passing = count(array_filter($checks, fn (array $check) => $check['ok']));
$feeds = count($report->metadata->feeds);
$errors = $report->advice->count('error');
$warnings = $report->advice->count('warning');
$tips = $report->advice->count('tip');

$items = [
    'microformats' => ['Microformats', $total === 1 ? '1 found' : "{$total} found"],
    'indieweb' => ['IndieWeb & rels', "{$passing} of " . count($checks) . ' checks pass'],
    'metadata' => ['Metadata', $feeds === 1 ? 'head tags, 1 feed' : "head tags, {$feeds} feeds"],
    'advice' => ['Advice', "{$errors} err · {$warnings} warn · {$tips} tips"],
    'json' => ['Raw JSON', 'canonical mf2 and more'],
];
?>
<nav class="bar" aria-label="Report sections">
    <?php foreach ($items as $anchor => [$name, $label]): ?>
        <a href="#<?= e($anchor) ?>"><span class="bar-label"><?= e($label) ?></span><strong><?= e($name) ?></strong></a>
    <?php endforeach ?>
</nav>