<?php get_header(); ?>

<div class="main">
	<div class="container">
		<div class="row justify-content-sm-center">
			<div class="col-sm-8">
				<?php
				if ( have_posts() ) :
				?>
					<main>
						<?php
						while ( have_posts() ) : the_post();
						?>
							<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
										<header class="entry-header">
											<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
										</header>

										<div class="entry-content">
											<?php
											if ( has_post_thumbnail() ) {
											?>
												<figure class="post-thumbnail">
													<a class="post-thumbnail-inner" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
														<?php the_post_thumbnail( 'post-thumbnail' ); ?>
													</a>
												</figure>
											<?php }

											the_excerpt();
											?>
										</div>

										<footer class="entry-footer">
											<?php
											printf(
												/* translators: 1: SVG icon. 2: post author, only visible to screen readers. 3: author link. */
												'<span class="byline">%1$s<span class="screen-reader-text">%2$s</span><span class="author vcard"><a class="url fn n" href="%3$s">%4$s</a></span></span>',
												'<i class="fas fa-user"></i>',
												__( 'Posted by', 'sbw-wedding' ),
												esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
												esc_html( get_the_author() )
											);

											$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
											if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
												$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
											}

											$time_string = sprintf(
												$time_string,
												esc_attr( get_the_date( DATE_W3C ) ),
												esc_html( get_the_date() ),
												esc_attr( get_the_modified_date( DATE_W3C ) ),
												esc_html( get_the_modified_date() )
											);

											printf(
												'<span class="posted-on">%1$s<a href="%2$s" rel="bookmark">%3$s</a></span>',
												'<i class="fas fa-clock"></i>',
												esc_url( get_permalink() ),
												$time_string
											);

											/* translators: used between list items, there is a space after the comma. */
											$categories_list = get_the_category_list( __( ', ', 'sbw-wedding' ) );
											if ( $categories_list ) {
												printf(
													/* translators: 1: SVG icon. 2: posted in label, only visible to screen readers. 3: list of categories. */
													'<span class="cat-links">%1$s<span class="screen-reader-text">%2$s</span>%3$s</span>',
													'<i class="fas fa-folder"></i>',
													__( 'Posted in', 'sbw-wedding' ),
													$categories_list
												); // WPCS: XSS OK.
											}

											$tags_list = get_the_tag_list( '<i class="fas fa-tag"></i>', ', ' );
											if ( $tags_list ) {
												printf(
													/* translators: 1: SVG icon. 2: posted in label, only visible to screen readers. 3: list of tags. */
													'<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
													__( 'Tags:', 'sbw-wedding' ),
													$tags_list
												);
											}
											?>
										</footer><!-- .entry-footer -->
									</article>
						<?php endwhile; ?>

						<?php
						the_posts_pagination(
							array(
								'mid_size'  => 2,
								'prev_text' => sprintf(
									'%s <span class="nav-prev-text">%s</span>',
									'<i class="fas fa-chevron-left"></i>',
									__( 'Newer posts', 'sbw-wedding' )
								),
								'next_text' => sprintf(
									'<span class="nav-next-text">%s</span> %s',
									__( 'Older posts', 'sbw-wedding' ),
									'<i class="fas fa-chevron-right"></i>'
								),
							)
						);
						?>
					</main>
				<?php endif; ?>
			</div>
		</div>
	</div>
</div>

<?php get_footer(); ?>
