Skip to content

Commit 7566d98

Browse files
committed
Optimized update list & fixed sw cache list.
1 parent 34b9ebd commit 7566d98

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

_includes/panel.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ <h3 data-toc-skip>
2828

2929
{% if post %}
3030
{% assign url = post.url | relative_url %}
31-
3231
<li><a href="{{ url }}">{{ post.title }}</a></li>
33-
34-
{% assign sum = sum | plus: 1 %}
35-
{% if sum >= MAX_SIZE %} {% break %} {% endif %}
36-
3732
{% endif %}
3833

3934
{% endfor %}

_includes/update-list.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@
77
{% endcomment %}
88

99
{% assign MAX_SIZE = 5 %}
10-
{% assign sum = 0 %}
11-
{% assign update_list = "" | split: "" %}
10+
11+
{% assign all_list = "" | split: "" %}
1212

1313
{% for entry in site.data.updates %}
1414
{% capture elem %}
1515
{{- entry.lastmod -}}::{{- entry.filename -}}
1616
{% endcapture %}
17-
18-
{% assign update_list = update_list | push: elem %}
17+
{% assign all_list = all_list | push: elem %}
1918
{% endfor %}
2019

21-
{% assign update_list = update_list | sort | reverse %}
20+
{% assign all_list = all_list | sort | reverse %}
21+
22+
{% assign update_list = "" | split: "" %}
23+
24+
{% for entry in all_list limit:MAX_SIZE %}
25+
{% assign update_list = update_list | push: entry %}
26+
{% endfor %}

assets/js/data/cache-list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ const include = [
5353
{% endfor %}
5454

5555
{% include update-list.html %}
56+
5657
{% for item in update_list %}
57-
{% assign url = item | split: "::" | last | prepend: "/posts/" | append: "/" %}
58+
{% assign url = item | split: "::" | last | url_encode | prepend: "/posts/" | append: "/" | relative_url %}
5859
{% assign post_list = post_list | push: url %}
5960
{% endfor %}
6061

0 commit comments

Comments
 (0)