<?php
/**
 * Componente de Breadcrumbs (Migas de Pan)
 * 
 * Uso:
 *   $breadcrumbs = [
 *       ['nombre' => 'Inicio', 'url' => 'index.php'],
 *       ['nombre' => 'Nombre Página'] // sin url = página actual
 *   ];
 *   include("breadcrumbs.php");
 */
?>
<nav class="breadcrumb-nav" aria-label="Migas de pan">
    <ol class="breadcrumb-list" itemscope itemtype="https://schema.org/BreadcrumbList">
        <?php foreach ($breadcrumbs as $i => $miga): ?>
            <li class="breadcrumb-item<?php echo (!isset($miga['url'])) ? ' active' : ''; ?>"
                itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">

                <?php if (isset($miga['url'])): ?>
                    <a href="<?php echo $miga['url']; ?>" itemprop="item">
                        <?php if ($i === 0): ?>
                            <i class="bi bi-house-door"></i>
                        <?php endif; ?>
                        <span itemprop="name"><?php echo $miga['nombre']; ?></span>
                    </a>
                <?php else: ?>
                    <span itemprop="name"><?php echo $miga['nombre']; ?></span>
                <?php endif; ?>

                <meta itemprop="position" content="<?php echo $i + 1; ?>">
            </li>
        <?php endforeach; ?>
    </ol>
</nav>
