{%- assign post = include.post -%} {%- assign foundImage = false -%} {%- assign imgAlt = false -%} {%- assign images = post.content | split:“<img ” -%} {%- for image in images -%}
{%- if image contains 'src=' -%} {%- if foundImage == false -%} {%- assign imgAlt = image | split: 'alt="' | last -%} {%- assign imgAlt = capt | split: '" />' | first -%} {%- assign foundImage = image | split:'src="' | last -%} {%- assign foundImage = foundImage | split:'" alt=' | first -%} {% break %} {%- endif -%} {%- endif -%}
{%- endfor -%} {%- if post.image -%} {%- assign foundImage = post.image -%}{%- endif -%}
<a class=“post-item” href=“{{ post.url | prepend: site.baseurl }}”>
{%- unless foundImage -%} <h3>{{ post.title | capitalize }}</h3> <small class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</small> <p class="description"> {%- if post.description -%} {{ post.description | strip_html | strip_newlines | truncate: 120 }} {%- else -%} {{ post.content | strip_html | strip_newlines | truncate: 120 }} {%- endif -%} </p> {%- else -%} <img src="{{ post.image | default: foundImage }}" alt="{{ imgAlt | default: post.title }}" /> <div class="image-caption"> <div class="post-title"><h3>{{ post.title | capitalize }}</h3></div> <small class="post-meta"> <time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished"> {{ post.date | date: "%b %-d, %Y" }} </time> </small> </div> {%- endunless -%}
</a>