<?php
/**
 * Archive template.
 *
 * @package EasySite_Pro
 */

get_header();
?>

<div class="easysite-container easysite-content-area <?php echo easysite_get_mod( 'easysite_show_sidebar', true ) ? 'has-sidebar' : ''; ?>">
	<div class="easysite-primary">
		<header class="easysite-archive-header">
			<?php the_archive_title( '<h1 class="easysite-page-title">', '</h1>' ); ?>
			<?php the_archive_description( '<div class="easysite-archive-desc">', '</div>' ); ?>
		</header>

		<?php if ( have_posts() ) : ?>
			<div class="easysite-posts-grid">
				<?php
				$first = true;
				while ( have_posts() ) :
					the_post();
					$featured = $first && is_home();
					$first    = false;
					?>
					<article <?php post_class( $featured ? 'easysite-post-card is-featured' : 'easysite-post-card' ); ?>>
						<?php if ( has_post_thumbnail() ) : ?>
							<a href="<?php the_permalink(); ?>" class="easysite-post-thumb"><?php the_post_thumbnail( 'easysite-card' ); ?></a>
						<?php endif; ?>
						<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
						<p class="easysite-meta"><?php echo esc_html( get_the_date() ); ?></p>
						<p><?php echo esc_html( wp_trim_words( get_the_excerpt(), 24 ) ); ?></p>
						<a class="easysite-read-more" href="<?php the_permalink(); ?>"><?php esc_html_e( 'Read more', 'easysite-pro' ); ?></a>
					</article>
				<?php endwhile; ?>
			</div>
			<?php the_posts_pagination(); ?>
		<?php else : ?>
			<p><?php esc_html_e( 'No posts found.', 'easysite-pro' ); ?></p>
		<?php endif; ?>
	</div>
	<?php if ( easysite_get_mod( 'easysite_show_sidebar', true ) ) : ?>
		<?php get_sidebar(); ?>
	<?php endif; ?>
</div>

<?php
get_footer();
