<?php
$prev_post = get_previous_post();
$next_post = get_next_post();
?>

<?php get_header() ?>

<section class="page single">
    <div class="page__row">
        <div class="page__left">
            <?php the_post_thumbnail('news_single'); ?>
        </div>
        <div class="page__right">
            <div class="page__titles">
                <div class="page__date"><?php echo formatDate(get_the_date()) ?></div>
                <h1 class="page__title"><?php the_title() ?></h1>
            </div>

            <div class="page__desc description">
                <?php the_content() ?>
            </div>
        </div>
    </div>

    <div class="single__buttons">
        <div class="single__button single__button1">
            <?php if (!empty($prev_post)): ?>
                <a href="<?php echo get_permalink($prev_post->ID); ?>">
                    <span><i class="fa-solid fa-angle-left"></i></span> <strong>POPRZEDNI WPIS</strong>
                </a>
            <?php endif; ?>
        </div>
        <div class="single__button single__button2">
            <a href="<?= home_url() ?>/category/blog/" class="button">WSZYSTKIE WPISY</a>
        </div>
        <div class="single__button single__button3">
            <?php if (!empty($next_post)): ?>
                <a href="<?php echo get_permalink($next_post->ID); ?>">
                    <strong>NASTĘPNY WPIS</strong> <span><i class="fa-solid fa-angle-right"></i></span>
                </a>
            <?php endif; ?>
        </div>
    </div>
</section>

<?php get_footer() ?>