-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.html
34 lines (33 loc) · 1.18 KB
/
macros.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{% macro post_preview(page) %}
<h2><a href="{{ page.permalink }}">{{ page.title }}</a></h2>
<article>
{% set_global image_url = false %}
{% set paragraphs = page.content | split(pat="\n") %}
{% for paragraph in paragraphs %}
{% if paragraph is containing("img") %}
{% for p in paragraph | split(pat='"') %}
{% if p is containing("image") %}
{% set_global image_url = p %}
{% break %}
{% endif %}
{% endfor %}
{% break %}
{% endif %}
{% endfor %}
{% set paragraphs = page.content | split(pat="\n") %}
{% for paragraph in paragraphs %}
{% if paragraph | wordcount > 20 %}
{% if image_url %}
<a href="{{ page.permalink }}">
<img class="latest-image-preview" src="{{ image_url | safe }}">
</a>
{% endif %}
{{ paragraph | safe}}
{% break %}
{% endif %}
{% endfor %}
<div class="continue">
<a href="{{ page.permalink }}">Continue Reading</a>
</div>
</article>
{% endmacro post_preview %}