<?php
/**
 * The template part for displaying services
 * @package Mega Construction
 * @subpackage mega_construction
 * @since 1.0
 */
?>
<?php 
  $mega_construction_archive_year  = get_the_time('Y'); 
  $mega_construction_archive_month = get_the_time('m'); 
  $mega_construction_archive_day = get_the_time('d'); 
?> 
<article class="blog-sec p-2 mb-4">
  <div class="mainimage">
    <?php
      if ( ! is_single() ) {
        // If not a single post, highlight the gallery.
        if ( get_post_gallery() ) {
          echo '<div class="entry-gallery">';
            echo ( get_post_gallery() );
          echo '</div>';
        };
      };
    ?>    
  </div>
  <h2><a href="<?php echo esc_url(get_permalink() ); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h2>
  <?php if(get_theme_mod('mega_construction_metafields_date',true) == 1 || get_theme_mod('mega_construction_metafields_author',true) == 1 || get_theme_mod('mega_construction_metafields_comment',true) == 1 || get_theme_mod( 'mega_construction_metafields_time',true) ==1 ){ ?>
    <div class="post-info py-2 mb-2">
      <?php if(get_theme_mod('mega_construction_metafields_date',true)==1){ ?>
        <i class="<?php echo esc_attr(get_theme_mod('mega_construction_postdate_icon',"fa fa-calendar pe-2" )); ?>"></i><a href="<?php echo esc_url( get_day_link( $mega_construction_archive_year, $mega_construction_archive_month, $mega_construction_archive_day)); ?>"><span class="entry-date ms-1 me-2"><?php echo esc_html( get_the_date() ); ?></span><span class="screen-reader-text"><?php echo esc_html( get_the_date() ); ?></span></a>
      <?php }?>
      <?php if(get_theme_mod('mega_construction_metafields_author',true)==1){ ?>
        <i class="<?php echo esc_attr(get_theme_mod('mega_construction_postauthor_icon',"fa fa-user pe-2" )); ?>"></i><a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' )) ); ?>"><span class="entry-author ms-1 me-2"> <?php the_author(); ?></span><span class="screen-reader-text"><?php the_author(); ?></span></a>
      <?php }?>
      <?php if(get_theme_mod('mega_construction_metafields_comment',true)==1){ ?>
        <i class="<?php echo esc_attr(get_theme_mod('mega_construction_postcomment_icon',"fa fa-comments pe-2" )); ?>"></i><span class="entry-comments ms-1 me-2"> <?php comments_number( __('0 Comments','mega-construction'), __('0 Comments','mega-construction'), __('% Comments','mega-construction') ); ?></span> 
      <?php }?>
      <?php if( get_theme_mod( 'mega_construction_metafields_time',true) != '') { ?>
        <i class="<?php echo esc_attr(get_theme_mod('mega_construction_posttime_icon',"fa fa-clock pe-2" )); ?>"></i><span class="entry-comments ms-1 me-2"><?php echo esc_html( get_the_time() ); ?></span>
      <?php }?>
    </div>
  <?php }?>
  <?php if(has_post_thumbnail()) { ?>
    <div class="feature-box"> 
      <?php the_post_thumbnail(); ?>
    </div>
    <hr>          
  <?php } ?>
  <?php if(get_theme_mod('mega_construction_blog_post_content') == 'Full Content'){ ?>
    <?php the_content(); ?>
  <?php }
  if(get_theme_mod('mega_construction_blog_post_content', 'Excerpt Content') == 'Excerpt Content'){ ?>
    <?php if(get_the_excerpt()) { ?>
      <div class="entry-content"><p class="m-0"><?php $mega_construction_excerpt = get_the_excerpt(); echo esc_html( mega_construction_string_limit_words( $mega_construction_excerpt, esc_attr(get_theme_mod('mega_construction_post_excerpt_number','20')))); ?> <?php echo esc_html( get_theme_mod('mega_construction_button_excerpt_suffix','...') ); ?></p></div>
    <?php }?>
  <?php }?>
  <?php if ( get_theme_mod('mega_construction_blog_button_text','Read Full') != '' ) {?>
    <div class="blogbtn mt-3">
      <a href="<?php echo esc_url( get_permalink() );?>" class="blogbutton-small hvr-sweep-to-right" title="<?php esc_attr_e( 'Read Full', 'mega-construction' ); ?>"><?php echo esc_html( get_theme_mod('mega_construction_blog_button_text',__('Read Full', 'mega-construction')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('mega_construction_blog_button_text',__('Read Full', 'mega-construction')) ); ?></span></a>
    </div>
  <?php }?>
</article>