<?php
/**
 * The template for displaying Author Detail
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package NDesign
 */
get_header();
?>
<!-- This sets the $curauth variable -->
<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
?>
<div class="container py-5">
	<div class="row">
		<div class="col-12 <?php if ( is_active_sidebar( 1 ) ) : ?>
		col-lg-8
		<?php endif; ?>">
		<div class="author-bio">
			<div class="media">
				<?php
				$avatar = get_avatar_url($curauth->ID);
				if($avatar !== FALSE): ?>
					<img src="<?php echo $avatar; ?>" alt="" class="img-fluid d-flex mr-3 rounded-circle author-img">
				<?php endif; ?>
				<div class="media-body">
					<h2><?php echo $curauth->nickname; ?></h2>
					<ul class="list-unstyled">
						<li class="mb-2">
							<a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a>
						</li>
						<li class="mb-2">
							<a href="mailto:<?php echo $curauth->user_email; ?>"><?php echo $curauth->user_email; ?></a>
						</li>
						<li class="mb-2">
							<?php echo $curauth->user_description; ?>
						</li>
					</ul>
				</div>
			</div>
		</div><!-- .author-bio -->
		<div id="primary" class="content-area">
			<main id="main" class="site-main">
				<div class="row">
					<div class="col-12 mt-3">
						<h2>Posts by <?php echo $curauth->nickname; ?>:</h2>
					</div>
					<?php
					if ( have_posts() ) :
						if ( is_home() && ! is_front_page() ) :
							?>
						<header>
							<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
						</header>
						<?php
					endif;
					/* Start the Loop */
					while ( have_posts() ) :
						the_post();
								/*
								 * Include the Post-Type-specific template for the content.
								 * If you want to override this in a child theme, then include a file
								 * called content-___.php (where ___ is the Post Type name) and that will be used instead.
								 */
								get_template_part( 'template-parts/content', get_post_type() );
							endwhile;
							the_posts_navigation();
						else :
							get_template_part( 'template-parts/content', 'none' );
						endif;
						?>
					</div>
				</main><!-- #main -->
			</div><!-- #primary -->
		</div>
		<div class="col-12 <?php if ( is_active_sidebar( 1 ) ) : ?>
		col-lg-4
		<?php endif; ?>">
		<?php get_sidebar(); ?>
	</div>
</div>
</div>
<?php
get_footer();
