Skip to content

Commit 2b89231

Browse files
committed
Improved post loading speed.
Also improved the layout for Home page.
1 parent 488a30d commit 2b89231

8 files changed

Lines changed: 64 additions & 69 deletions

File tree

_includes/head.html

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<head>
88
<title>
9-
{%- if page.layout == "home" -%}
10-
{{- site.title -}}
11-
{%- else -%}
12-
{{ page.title }} | {{ site.title }}
13-
{%- endif -%}
9+
{%- if page.layout == "home" -%}
10+
{{- site.title -}}
11+
{%- else -%}
12+
{{ page.title }} | {{ site.title }}
13+
{%- endif -%}
1414
</title>
1515
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
1616
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@@ -50,4 +50,18 @@
5050
{% include google-analytics.html %}
5151
{% endif %}
5252

53+
{% if page.layout == 'home' or page.layout == 'post' %}
54+
<script src="{{ site.baseurl }}/assets/js/dist/timeago.min.js"></script>
55+
{% if site.google_analytics.pv %}
56+
<script src="{{ site.baseurl }}/assets/js/dist/countUp.min.js" async></script>
57+
<script src="{{ site.baseurl }}/assets/js/dist/pageviews.min.js" async></script>
58+
{% endif %}
59+
{% endif %}
60+
61+
{% if page.layout == 'post' and site.toc and page.toc %}
62+
<link rel="stylesheet" href="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.css" />
63+
<script src="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script>
64+
<script src="{{ site.baseurl }}/assets/js/dist/toc.min.js"></script>
65+
{% endif %}
66+
5367
</head>

_includes/panel.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
MIT License
55
-->
66

7-
<div class="panel-group">
7+
<div id="panel-wrap" class="col-xl-3 pl-2 topbar-down">
88

9+
<div class="access">
910
{% assign lastmod_list = "" | split: "" %}
1011
{% assign index = 0 %}
1112

@@ -20,7 +21,7 @@
2021
{% endfor %}
2122

2223
{% if lastmod_list.size > 0 %}
23-
<div id="panel-update" class="post mb-4"">
24+
<div id="access-lastmod" class="post mb-4"">
2425
<h3 data-toc-skip>
2526
{{ site.data.label.panel.lastmod }}
2627
</h3>
@@ -41,7 +42,7 @@ <h3 data-toc-skip>
4142
</div><!-- #panel-update -->
4243
{% endif %}
4344

44-
<div id="panel-tags">
45+
<div id="access-tags">
4546
<h3 data-toc-skip>
4647
{{ site.data.label.panel.trending_tags }}
4748
</h3>
@@ -69,5 +70,15 @@ <h3 data-toc-skip>
6970

7071
</div>
7172
</div><!-- #panel-tags -->
73+
</div>
7274

73-
</div>
75+
{% if page.layout == 'post' and site.toc and page.toc %}
76+
<div id="toc-wrap" class="pl-0 pr-4">
77+
<h3 data-toc-skip class="pl-3 pt-2">
78+
{{- site.data.label.panel.toc -}}
79+
</h3>
80+
<nav id="toc" data-toggle="toc"></nav>
81+
</div>
82+
{% endif %}
83+
84+
</div> <!-- #panel-wrap -->

_layouts/home.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,3 @@ <h1>
119119

120120
</ul> <!-- .pagination -->
121121
{% endif %}
122-
123-
<script src="{{ site.baseurl }}/assets/js/dist/timeago.min.js"></script>
124-
125-
{% if site.google_analytics.pv %}
126-
<script src="{{ site.baseurl }}/assets/js/dist/countUp.min.js" async></script>
127-
<script src="{{ site.baseurl }}/assets/js/dist/pageviews.min.js" async></script>
128-
{% endif %}

_layouts/page.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,4 @@ <h1 class="dynamic-title">{{ page.title }}</h1>
2424
</div> <!-- #page -->
2525
</div><!-- end .col-12 -->
2626

27-
<div id="panel-wrap" class="col-xl-3 pl-2">
28-
{% include panel.html %}
29-
</div>
27+
{% include panel.html %}

_layouts/post.html

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,4 @@ <h1 data-toc-skip>{{ page.title }}</h1>
9696
</div> <!-- #post-wrap -->
9797
</div> <!-- div.col-12..col-lg-11.col-xl-8 -->
9898

99-
<div id="post-panel" class="col-xl-3 pl-2">
100-
{% include panel.html %}
101-
{% if site.toc and page.toc %}
102-
<div id="toc-wrap" class="topbar-down pr-4">
103-
<h3 data-toc-skip class="pl-3 pt-2">
104-
{{- site.data.label.panel.toc -}}
105-
</h3>
106-
<nav id="toc" data-toggle="toc"></nav>
107-
</div>
108-
<link rel="stylesheet" href="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.css" />
109-
<script src="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script>
110-
<script src="{{ site.baseurl }}/assets/js/dist/toc.min.js"></script>
111-
{% endif %}
112-
</div> <!-- #post-panel -->
113-
114-
<script src="{{ site.baseurl }}/assets/js/dist/timeago.min.js"></script>
115-
116-
{% if site.google_analytics.pv %}
117-
<script src="{{ site.baseurl }}/assets/js/dist/countUp.min.js" async></script>
118-
<script src="{{ site.baseurl }}/assets/js/dist/pageviews.min.js" async></script>
119-
{% endif %}
99+
{% include panel.html %}

assets/css/_src/main.scss

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,7 @@ footer .license a {
378378

379379

380380
/*--- Panels ---*/
381-
.panel-group {
382-
position: -webkit-sticky; /* Safari */
383-
position: sticky;
381+
.access {
384382
top: 2rem;
385383
transition: top 0.2s ease-in-out;
386384
margin-right: 1.5rem;
@@ -389,20 +387,25 @@ footer .license a {
389387
color: #6c757d;
390388
}
391389

392-
.panel-group.topbar-down {
390+
.access:only-child {
391+
position: -webkit-sticky; /* Safari */
392+
position: sticky;
393+
}
394+
395+
.access.topbar-down {
393396
top: 6rem;
394397
}
395398

396-
.panel-group>div {
399+
.access>div {
397400
padding-left: 1rem;
398401
border-left: 1px solid rgba(158, 158, 158, 0.17);
399402
}
400403

401-
.panel-group>div:not(:first-child) {
404+
.access>div:not(:first-child) {
402405
margin-top: 4rem;
403406
}
404407

405-
.panel-group h3 {
408+
.access h3 {
406409
padding-top: .5rem;
407410
padding-bottom: .5rem;
408411
margin-top: 0;
@@ -412,15 +415,15 @@ footer .license a {
412415
font-family: 'Oswald', sans-serif;
413416
}
414417

415-
.panel-group .post-content {
418+
.access .post-content {
416419
font-size: .9rem;
417420
}
418421

419-
#panel-tags>div.post-content>div {
422+
#access-tags>div.post-content>div {
420423
max-width: 80%;
421424
}
422425

423-
#panel-tags .post-tag {
426+
#access-tags .post-tag {
424427
display: inline-block;
425428
line-height: 1rem;
426429
font-size: 0.85rem;
@@ -431,14 +434,14 @@ footer .license a {
431434
margin-bottom: .3rem;
432435
}
433436

434-
#panel-tags .post-tag:hover {
437+
#access-tags .post-tag:hover {
435438
background-color: #2a408e;
436439
border-color: #2a408e;
437440
color: #fff;
438441
transition: none;
439442
}
440443

441-
#panel-update ul>li {
444+
#access-lastmod ul>li {
442445
height: 1.8rem;
443446
overflow: hidden;
444447
text-overflow: ellipsis;
@@ -448,7 +451,7 @@ footer .license a {
448451
list-style: none;
449452
}
450453

451-
#panel-update ul a {
454+
#access-lastmod ul a {
452455
color: #6c757d;
453456
}
454457

@@ -585,7 +588,7 @@ p>a, span>a,
585588
}
586589

587590
.categories a,
588-
.panel-group a,
591+
.access a,
589592
#archives a,
590593
#page-tag a,
591594
#page-category a,
@@ -606,7 +609,7 @@ p>a, span>a,
606609
footer a:hover,
607610
#post-wrap .post-content a:hover,
608611
#page .post-content a:hover,
609-
#panel-update a:hover {
612+
#access-lastmod a:hover {
610613
color: #d2603a;
611614
border-bottom: 1px solid #d2603a;
612615
text-decoration: none;
@@ -819,10 +822,6 @@ table tbody td {
819822
filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.08));
820823
}
821824

822-
#post-panel .panel-group {
823-
position: static;
824-
}
825-
826825
#toc-wrap {
827826
border-left: 1px solid rgba(158, 158, 158, 0.17);
828827
position: -webkit-sticky;
@@ -1164,7 +1163,7 @@ a.tag:hover {
11641163

11651164
#page-category a:hover,
11661165
#page-tag a:hover,
1167-
#panel-update a:hover {
1166+
#access-lastmod a:hover {
11681167
margin-bottom: -1px; // Avoid jumping
11691168
}
11701169

@@ -1497,12 +1496,12 @@ div.tooltip-inner { /* Overrided BS4 Tooltip */
14971496

14981497
/* Pannel hidden */
14991498
@media all and (max-width: 1200px) {
1500-
#post-list {
1501-
padding-right: 0;
1499+
#panel-wrap {
1500+
display: none;
15021501
}
15031502

1504-
#panel-wrap, #post-panel {
1505-
display: none;
1503+
#post-list {
1504+
padding-right: 0;
15061505
}
15071506

15081507
.pagination {

assets/js/_src/_commons/topbar-switch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ $(function() {
3838
$('#toc-wrap').removeClass('topbar-down');
3939
}
4040

41-
if ( $('.panel-group').length > 0) {
42-
$('.panel-group').removeClass('topbar-down');
41+
if ( $('.access').length > 0) {
42+
$('.access').removeClass('topbar-down');
4343
}
4444

4545
if ($('#search-input').is(':focus')) {
@@ -53,8 +53,8 @@ $(function() {
5353
if ( $('#toc-wrap').length > 0) {
5454
$('#toc-wrap').addClass('topbar-down');
5555
}
56-
if ( $('.panel-group').length > 0) {
57-
$('.panel-group').addClass('topbar-down');
56+
if ( $('.access').length > 0) {
57+
$('.access').addClass('topbar-down');
5858
}
5959
}
6060
}

assets/js/dist/_commons/topbar-switch.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)