{{ define "main" }}
<section class="home-about">
	<div class="avatar">
        {{ if isset .Site.Params "avatarurl" }}
        <img class={{ .Site.Params.AvatarSize | default "size-m" }} src='{{ .Scratch.Get "avatarImgSrc" }}' alt="{{ .Site.Params.AvatarAltText|default "avatar" }}" />
        {{ end }}
	</div>

    <h1>{{ .Site.Title }}</h1>
    {{ if isset .Site.Params "description" }}
        <h3>{{ .Site.Params.Description }}</h3>
    {{ end }}

</section>

<div class="flex-break"></div>

{{ if isset .Site.Params "socialicons" }}
<section class="social-icons">
    <ul class="social-icons-list">
        {{ range .Site.Params.SocialIcons }}
        <li class="social-icon">
            <a href="{{ .url }}" {{ if .rel }}rel="{{ .rel }}"{{ end }} aria-label="Learn more on {{ .name }}">
                <img class="svg-inject" src="/svg/icons/{{ .name }}.svg" />
            </a>
        </li>
        {{ end }}
    </ul>
</section>
{{ end }}

{{ if os.FileExists "index-about.md" }}
<div class="markdown-content">
    {{ readFile "index-about.md" | markdownify }}
</div>
{{ end }}

{{ if isset .Site.Params "showpostsonhomepage" }}

    <div class="home-posts list-posts">
        <h2>{{ i18n (.Site.Params.ShowPostsOnHomePage | humanize) }} Posts</h2>

    {{ $posts := where .Site.Pages "Params.type" "post" }}

    {{ if eq .Site.Params.ShowPostsOnHomePage "popular" }}
        {{ range $posts.ByWeight | first 4 }}
            {{- partial "list-posts.html" . -}}
        {{ end }}
    {{ else if eq .Site.Params.ShowPostsOnHomePage "recent" }}
        {{ range $posts.ByDate.Reverse | first 4 }}
            {{- partial "list-posts.html" . -}}
        {{ end }}
    {{ end }}
    </div>

{{ end }}
{{ end }}
