Skip to content

Commit db2de86

Browse files
Optimization
1 parent a053e4b commit db2de86

File tree

7 files changed

+32
-29
lines changed

7 files changed

+32
-29
lines changed

default.hbs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
}
2222
</style>
2323

24-
<script src="http://localhost:35729/livereload.js?snipver=1"></script>
25-
2624
<script>
2725
/* The script for calculating the color contrast has been taken from
2826
https://gomakethings.com/dynamically-changing-the-text-color-based-on-background-color-contrast-with-vanilla-js/ */

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@
6363
"config": {
6464
"posts_per_page": 16,
6565
"image_sizes": {
66-
"xxs": {
67-
"width": 30
68-
},
6966
"xs": {
70-
"width": 100
67+
"width": 160
7168
},
7269
"s": {
73-
"width": 300
70+
"width": 320
7471
},
7572
"m": {
7673
"width": 600
7774
},
7875
"l": {
79-
"width": 1000
76+
"width": 960
8077
},
8178
"xl": {
79+
"width": 1200
80+
},
81+
"xxl": {
8282
"width": 2000
8383
}
8484
},

partials/components/featured.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<h2 class="gh-featured-title">Featured</h2>
66
<div class="gh-featured-feed">
77
{{#foreach featured}}
8-
{{> "post-card"}}
8+
{{> "post-card" imageSizes="80px"}}
99
{{/foreach}}
1010
</div>
1111
</div>

partials/components/header-content.hbs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{{#match headerStyle "Highlight"}}
1818
<div class="gh-header-left">
1919
{{#foreach posts limit="1"}}
20-
{{> "post-card"}}
20+
{{> "post-card" imageSizes="(max-width: 767px) calc(100vw - max(8vmin, 40px)), 640px"}}
2121
{{/foreach}}
2222
</div>
2323
<div class="gh-header-middle">
@@ -31,7 +31,7 @@
3131
{{else}}
3232
<div class="gh-featured-feed">
3333
{{#foreach posts from="5" limit="6"}}
34-
{{> "post-card"}}
34+
{{> "post-card" imageSizes="80px"}}
3535
{{/foreach}}
3636
</div>
3737
{{/if}}
@@ -47,7 +47,11 @@
4747
{{#match @number 5}}
4848
<div class="gh-header-right">
4949
{{/match}}
50-
{{> "post-card"}}
50+
{{#if @first}}
51+
{{> "post-card" imageSizes="640px"}}
52+
{{else}}
53+
{{> "post-card"}}
54+
{{/if}}
5155
{{#match @number 4}}
5256
</div>
5357
{{/match}}

partials/components/post-list.hbs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
{{#match posts.length ">=" 4}}
2626
{{#get "posts" include="authors" limit="16"}}
2727
{{#foreach posts from="5" limit="12"}}
28-
{{> "post-card"}}
28+
{{> "post-card" lazyLoad=true}}
2929
{{/foreach}}
3030
{{/get}}
3131
{{/match}}
3232
{{else}}
3333
{{#match posts.length ">=" 10}}
3434
{{#get "posts" include="authors" limit="22"}}
3535
{{#foreach posts from="11" limit="12"}}
36-
{{> "post-card"}}
36+
{{> "post-card" lazyLoad=true}}
3737
{{/foreach}}
3838
{{/get}}
3939
{{/match}}
@@ -42,14 +42,14 @@
4242
{{#match posts.length ">=" 7}}
4343
{{#get "posts" include="authors" limit="19"}}
4444
{{#foreach posts from="8" limit="12"}}
45-
{{> "post-card"}}
45+
{{> "post-card" lazyLoad=true}}
4646
{{/foreach}}
4747
{{/get}}
4848
{{/match}}
4949
{{else}}
5050
{{#get "posts" include="authors" limit="12"}}
5151
{{#foreach posts}}
52-
{{> "post-card"}}
52+
{{> "post-card" lazyLoad=true}}
5353
{{/foreach}}
5454
{{/get}}
5555
{{/match}}
@@ -65,22 +65,22 @@
6565
{{/get}}
6666
{{/match}}
6767
{{#foreach posts}}
68-
{{> "post-card"}}
68+
{{> "post-card" lazyLoad=true}}
6969
{{/foreach}}
7070
{{/match}}
7171

7272
{{!-- Tag and author pages --}}
7373
{{#match feed "archive"}}
7474
{{#foreach posts}}
75-
{{> "post-card"}}
75+
{{> "post-card" lazyLoad=true}}
7676
{{/foreach}}
7777
{{/match}}
7878

7979
{{!-- Recent posts --}}
8080
{{#match feed "recent"}}
8181
{{#get "posts" include="authors" filter="id:-{{post.id}}" limit="4" as |next|}}
8282
{{#foreach next}}
83-
{{> "post-card"}}
83+
{{> "post-card" lazyLoad=true}}
8484
{{/foreach}}
8585
{{/get}}
8686
{{/match}}
@@ -92,7 +92,7 @@
9292
<aside class="gh-sidebar">
9393
<section class="gh-about">
9494
{{#if @site.icon}}
95-
<img class="gh-about-icon" src="{{@site.icon}}" alt="{{@site.title}}">
95+
<img class="gh-about-icon" src="{{@site.icon}}" alt="{{@site.title}}" loading="lazy">
9696
{{/if}}
9797
<h3 class="gh-about-title is-title">{{@site.title}}</h3>
9898
{{#if @site.description}}

partials/feature-image.hbs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{{#if feature_image}}
22
<figure class="gh-article-image">
33
<img
4-
srcset="{{img_url feature_image size="s"}} 300w,
5-
{{img_url feature_image size="m"}} 720w,
4+
srcset="{{img_url feature_image size="s"}} 320w,
5+
{{img_url feature_image size="m"}} 600w,
66
{{img_url feature_image size="l"}} 960w,
77
{{img_url feature_image size="xl"}} 1200w,
88
{{img_url feature_image size="xxl"}} 2000w"
9-
sizes="(max-width: 1200px) 100vw, 1200px"
109
src="{{img_url feature_image size="xl"}}"
1110
alt="{{title}}"
1211
>

partials/post-card.hbs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
{{#if feature_image}}
44
<figure class="gh-card-image">
55
<img
6-
srcset="{{img_url feature_image size="s"}} 300w,
7-
{{img_url feature_image size="m"}} 720w,
8-
{{img_url feature_image size="l"}} 960w,
9-
{{img_url feature_image size="xl"}} 1200w,
10-
{{img_url feature_image size="xxl"}} 2000w"
11-
sizes="(max-width: 1200px) 100vw, 1200px"
6+
srcset="{{img_url feature_image size="xs" format="webp"}} 160w,
7+
{{img_url feature_image size="s" format="webp"}} 320w,
8+
{{img_url feature_image size="m" format="webp"}} 600w,
9+
{{img_url feature_image size="l" format="webp"}} 960w,
10+
{{img_url feature_image size="xl" format="webp"}} 1200w,
11+
{{img_url feature_image size="xxl" format="webp"}} 2000w"
12+
sizes="{{#if imageSizes}}{{imageSizes}}{{else}}320px{{/if}}"
1213
src="{{img_url feature_image size="m"}}"
1314
alt="{{#if feature_image_alt}}{{feature_image_alt}}{{else}}{{title}}{{/if}}"
15+
{{#if lazyLoad}}loading="lazy"{{/if}}
1416
>
1517
</figure>
1618
{{/if}}

0 commit comments

Comments
 (0)