<?php
/**
 * Template part for displaying breadcrumbs.
 *
 * @package Eronex
 * @since 0.0.1
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$breadcrumbs = eronex_breadcrumbs_list();
$typo         = eronex_option( 'eronex_breadcrumb_family', 'primary' );
$title_class  = 'primary' === $typo ? ' eronex-main-font' : ' eronex-alt-font';
?>
<div class="eronex-breadcrumbs" aria-label="<?php echo esc_attr__( 'Breadcrumb', 'eronex' ); ?>">
	<div class="eronex-breadcrumb-list">
		<?php foreach ( $breadcrumbs as $index => $breadcrumb ) : ?>
			<?php if ( ! empty( $breadcrumb['url'] ) ) : ?>
				<a class="eronex-breadcrumb-item" href="<?php echo esc_url( $breadcrumb['url'] ); ?>"
					class="<?php echo esc_attr( $breadcrumb['class'] ?? '' ); ?>">
					<?php echo esc_html( $breadcrumb['title'] ); ?>
				</a>
			<?php else : ?>
				<span class="eronex-breadcrumb-item">
					<?php echo esc_html( $breadcrumb['title'] ); ?>
				</span>
			<?php endif; ?>
			<?php
			if ( $index < count( $breadcrumbs ) - 1 ) :
				?>
				<span class="eronex-breadcrumb-separator">
					<i class="hi hi-chevron-right" aria-hidden="true"></i>
				</span>
			<?php endif; ?>
		<?php endforeach; ?>
	</div>
</div>
