<?php
if( !defined('ABSPATH') ){ exit(); }
get_header();
?>
<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <?php the_title('<h1>', '</h1>'); ?>
        <?php if( is_single() ): ?>
            <div>
                <span><?= get_the_date(); ?> | <?php the_author(); ?></span>
            </div>
        <?php endif; ?>

        <?php if( has_post_thumbnail() ): ?>
            <div><?php the_post_thumbnail('large', ['loading' => 'lazy']); ?></div>
        <?php endif; ?>

        <div>
            <?php
            the_content();
            wp_link_pages([
                'before' => '<div>Pages:',
                'after'  => '</div>',
            ]);
            ?>
        </div>

        <?php
        if (is_single()) :
            $categories = get_the_category_list(', ');
            $tags       = get_the_tag_list('', ', ');
            if( $categories ){ echo '<div>Category: ' . $categories . '</div>'; }
            if( $tags ){ echo '<div>Tags: ' . $tags . '</div>'; }
        endif;
        ?>
    </article>

    <?php
    if (comments_open() || get_comments_number()) :
        comments_template();
    endif;
    ?>

    <?php if (is_single()) : ?>
        <nav>
            <?php
            the_post_navigation([
                'prev_text' => '← %title',
                'next_text' => '%title →',
            ]);
            ?>
        </nav>
    <?php endif; ?>

<?php endwhile; endif; ?>

<?php get_footer(); ?>