<?php
defined('ABSPATH') || exit;
?>
<article class="kb-doc-content">
    <header class="kb-doc-header">
        <div class="kb-doc-header__main">
            <nav class="kb-breadcrumbs">
                <a href="<?php echo esc_url($url_builder::docsIndex()); ?>"><?php esc_html_e('Dokumentation', 'kb-markdown-importer'); ?></a><span>/</span>
                <a href="<?php echo esc_url($url_builder::product($product_slug)); ?>"><?php echo esc_html($product ? $product->name : $product_slug); ?></a><span>/</span>
                <span><?php echo esc_html($version ? $version->name : $version_slug); ?></span>
            </nav>
            <h1><?php echo esc_html(get_the_title($post)); ?></h1>
        </div>
        <?php if (! empty($versions)) : ?>
            <div class="kb-version-switcher">
                <label for="kb-version-switcher"><?php esc_html_e('Version', 'kb-markdown-importer'); ?></label>
                <select id="kb-version-switcher">
                    <?php foreach ((array) $versions as $available_version) : ?>
                        <option value="<?php echo esc_attr($available_version->slug); ?>" data-url="<?php echo esc_url($url_builder::version($product_slug, $available_version->slug)); ?>" <?php selected($available_version->slug, $version_slug); ?>>
                            <?php echo esc_html($available_version->name); ?>
                        </option>
                    <?php endforeach; ?>
                </select>
            </div>
        <?php endif; ?>
    </header>
    <div class="kb-rendered-content">
        <?php
        $rendered_content = $url_builder::rewriteHtml(apply_filters('the_content', $post->post_content));
        echo wp_kses_post($rendered_content);
        ?>
    </div>
</article>
