<?php
defined('ABSPATH') || exit;
?>
<main class="kb-docs-wrap">
    <h1><?php esc_html_e('Knowledgebase', 'kb-markdown-importer'); ?></h1>
    <?php echo do_shortcode('[kb_search]'); ?>
    <div class="kb-product-list">
        <?php foreach ((array) $products as $item) : ?>
            <?php $term = $item['term']; ?>
            <section class="kb-product-card">
                <h2><a href="<?php echo esc_url($url_builder::product($term->slug)); ?>"><?php echo esc_html($term->name); ?></a></h2>
                <?php if (! empty($item['versions'])) : ?>
                    <ul>
                        <?php foreach ($item['versions'] as $version) : ?>
                            <li><a href="<?php echo esc_url($url_builder::version($term->slug, $version->slug)); ?>"><?php echo esc_html($version->name); ?></a></li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </section>
        <?php endforeach; ?>
    </div>
</main>
