<?php
/**
 * Template part for displaying posts
 *
 * @package ChaletMontagne
 * @since 1.0.0
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <?php
        if (is_singular()) :
            the_title('<h1 class="entry-title">', '</h1>');
        else :
            the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>');
        endif;

        if ('post' === get_post_type()) :
            ?>
            <div class="entry-meta">
                <?php
                chaletmontagne_posted_on();
                chaletmontagne_posted_by();
                ?>
            </div><!-- .entry-meta -->
        <?php endif; ?>
    </header><!-- .entry-header -->

    <?php if (has_post_thumbnail()) : ?>
        <figure class="post-thumbnail featured-image-container <?php echo is_singular() ? 'featured-image-single' : 'featured-image-archive'; ?>">
            <?php if (is_singular()) : ?>
                <div class="featured-image-frame">
                    <?php the_post_thumbnail('large', array(
                        'class' => 'featured-image',
                        'loading' => 'eager'
                    )); ?>
                    <div class="featured-image-overlay"></div>
                </div>
                <?php
                $caption = get_the_post_thumbnail_caption();
                if ($caption) : ?>
                    <figcaption class="featured-image-caption"><?php echo esc_html($caption); ?></figcaption>
                <?php endif; ?>
            <?php else : ?>
                <a href="<?php the_permalink(); ?>" class="featured-image-link">
                    <?php the_post_thumbnail('medium_large', array(
                        'class' => 'featured-image'
                    )); ?>
                    <div class="featured-image-hover-overlay"></div>
                </a>
            <?php endif; ?>
        </figure>
    <?php endif; ?>

    <div class="entry-content">
        <?php
        if (is_singular()) :
            the_content(sprintf(
                wp_kses(
                    /* translators: %s: Name of current post. Only visible to screen readers */
                    __('Continuer la lecture<span class="screen-reader-text"> de %s</span>', 'chalet-montagne'),
                    array(
                        'span' => array(
                            'class' => array(),
                        ),
                    )
                ),
                wp_kses_post(get_the_title())
            ));
        else :
            the_excerpt();
        endif;

        wp_link_pages(array(
            'before' => '<div class="page-links">' . esc_html__('Pages:', 'chalet-montagne'),
            'after'  => '</div>',
        ));
        ?>
    </div><!-- .entry-content -->

    <footer class="entry-footer">
        <?php chaletmontagne_entry_footer(); ?>
    </footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->
