<?php

/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package  News Axis
 */
$news_axis_blog_style = get_theme_mod('news_axis_blog_style', 'grid');
if ($news_axis_blog_style == 'grid' && !is_single()) :
	get_template_part('template-parts/content', 'grid');
elseif ($news_axis_blog_style == 'list' && !is_single()) :
	get_template_part('template-parts/content', 'list');
else :
?>

	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<div class="xpost-item pb-5 mb-5">
			<div class="xpost-text p-3">
				<?php if (has_category()) : ?>
					<div class="news-axis-category">
						<?php the_category(' '); ?>
					</div>
				<?php endif; ?>
				<header class="entry-header pb-4">
					<?php
					the_title('<h1 class="entry-title news-axis-title">', '</h1>');

					if ('post' === get_post_type()) :
					?>
						<div class="news-axis-meta">
							<img
								src="<?php echo esc_url(get_avatar_url(get_the_author_meta('ID'))); ?>"
								alt="<?php echo esc_attr(get_the_author()); ?>"
								class="news-axis-author-img">
							<span class="news-axis-author">
								<?php
								printf(
									esc_html__('By %s', 'news-axis'),
									esc_html(get_the_author())
								);
								?>
							</span>
							<span class="news-axis-date">
								<?php echo esc_html(get_the_date(get_option('date_format'))); ?>
							</span>
						</div>

					<?php endif; ?>
				</header><!-- .entry-header -->
				<?php news_axis_post_thumbnail(); ?>

				<div class="entry-content">
					<?php
					if (is_single()) {
						the_content(
							sprintf(
								wp_kses(
									/* translators: %s: Name of current post. Only visible to screen readers */
									__('Continue reading<span class="screen-reader-text"> "%s"</span>', 'news-axis'),
									array(
										'span' => array(
											'class' => array(),
										),
									)
								),
								wp_kses_post(get_the_title())
							)
						);

						wp_link_pages(
							array(
								'before' => '<div class="page-links">' . esc_html__('Pages:', 'news-axis'),
								'after'  => '</div>',
							)
						);
					} else {
						the_excerpt();
					}

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