Skip to content

Commit 376ffa8

Browse files
committed
Optimized the Post layout.
1 parent 8f47ba6 commit 376ffa8

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

_layouts/post.html

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,17 @@ <h1 data-toc-skip>{{ page.title }}</h1>
4545

4646
</div> <!-- .post-meta -->
4747

48-
{% capture post_content %}
4948
<div class="post-content">
5049
{% if page.image %}
5150
<img src="{{ page.image }}">
5251
{% endif %}
53-
{{ content }}
52+
<!-- Add lozad class into image tags. see: <https://github.com/ApoorvSaxena/lozad.js#usage> -->
53+
{% if content contains '<img src=' %}
54+
{{ content | replace: '<img src=', '<img class="lozad" src="/assets/img/commons/loading.png" data-src=' }}
55+
{% else %}
56+
{{ content }}
57+
{% endif %}
5458
</div>
55-
{% endcapture %}
56-
57-
<!-- Add lozad class into image tags. see: <https://github.com/ApoorvSaxena/lozad.js#usage> -->
58-
{% if post_content contains '<img src=' %}
59-
{{ post_content | replace: '<img src=', '<img class="lozad" src="/assets/img/commons/loading.png" data-src=' }}
60-
{% else %}
61-
{{ post_content }}
62-
{% endif %}
6359
6460
<div class="post-tail text-muted">
6561
<!-- Tags -->

0 commit comments

Comments
 (0)