{{ if isset .Site.Params "recent_posts" }}
{{ if .Site.Params.recent_posts.enable }}
<section class="bar background-white no-mb">
    <div class="container">

        <div class="col-md-12">
            <div class="heading text-center">
                <h2>{{ .Site.Params.recent_posts.title | markdownify }}</h2>
            </div>

            <p class="lead">
              {{ .Site.Params.recent_posts.subtitle | markdownify }}
            </p>

            <!-- *** BLOG HOMEPAGE *** -->

            <div class="row">
                {{ $posts := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }}
                {{ range first 4 $posts.Pages }}
                <div class="col-md-3 col-sm-6">
                    <div class="box-image-text blog">
                        <div class="top">
                            <div class="image" style="overflow:hidden">
                                {{ if isset .Params "banner" }}
                                <img src="{{ .Params.banner | relURL }}" class="img-responsive" alt="" />
                                {{ else }}
                                <img src="{{ "img/placeholder.png" | relURL }}" class="img-responsive" alt="" />
                                {{ end }}
                            </div>
                            <div class="bg"></div>
                            <div class="text">
                                <p class="buttons">
                                    <a href="{{ .Permalink }}" class="btn btn-template-transparent-primary"><i class="fas fa-link"></i> {{ i18n "readMore" }}</a>
                                </p>
                            </div>
                        </div>

                        <div class="content">
                            <h4><a href="{{ .Permalink }}">{{ .Title }}</a></h4>
                            <p class="author-category">
			    {{ if isset .Params "authors" }}
			      {{ i18n "authorBy" }} {{ range $index, $author := .Params.authors }}{{ if $index }}, {{ end }}<a href="{{ (printf "%s/%s" ("authors" | relLangURL) ($author | urlize)) }}">{{ $author }}</a>{{ end }}
                            {{ end }}
                            {{ if .Params.date }}
                                {{ $createdAt := .Date.Format .Site.Params.date_format }}
                                {{ range $index, $month := slice "January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December" }}
                                    {{ $createdAt = replace $createdAt $month (i18n $month) }}
                                {{ end }}
                                {{ i18n "publishedOn" }} {{ $createdAt }}
                            {{ end }}
                            </p>
                            {{ if not .Site.Params.recent_posts.hide_summary }}
                            <p class="intro">{{ .Summary }}</p>
                            <p class="read-more">
                              <a href="{{ .Permalink }}" class="btn btn-template-main">{{ i18n "continueReading" }}</a>
                            </p>
                            {{ end }}
                        </div>
                    </div>
                    <!-- /.box-image-text -->

                </div>
                {{ end }}

            </div>
            <!-- /.row -->

            <!-- *** BLOG HOMEPAGE END *** -->

        </div>
    </div>
    <!-- /.container -->
</section>
<!-- /.bar -->
{{ end }}
{{ end }}
