Optimized update list & fixed sw cache list.

This commit is contained in:
Cotes Chung 2020-07-15 16:49:02 +08:00
parent 9f3619e54a
commit 22115f3797
3 changed files with 12 additions and 11 deletions

View file

@ -28,12 +28,7 @@
{% if post %}
{% assign url = post.url | relative_url %}
<li><a href="{{ url }}">{{ post.title }}</a></li>
{% assign sum = sum | plus: 1 %}
{% if sum >= MAX_SIZE %} {% break %} {% endif %}
{% endif %}
{% endfor %}

View file

@ -7,15 +7,20 @@
{% endcomment %}
{% assign MAX_SIZE = 5 %}
{% assign sum = 0 %}
{% assign update_list = "" | split: "" %}
{% assign all_list = "" | split: "" %}
{% for entry in site.data.updates %}
{% capture elem %}
{{- entry.lastmod -}}::{{- entry.filename -}}
{% endcapture %}
{% assign update_list = update_list | push: elem %}
{% assign all_list = all_list | push: elem %}
{% endfor %}
{% assign update_list = update_list | sort | reverse %}
{% assign all_list = all_list | sort | reverse %}
{% assign update_list = "" | split: "" %}
{% for entry in all_list limit:MAX_SIZE %}
{% assign update_list = update_list | push: entry %}
{% endfor %}

View file

@ -53,8 +53,9 @@ const include = [
{% endfor %}
{% include update-list.html %}
{% for item in update_list %}
{% assign url = item | split: "::" | last | prepend: "/posts/" | append: "/" %}
{% assign url = item | split: "::" | last | url_encode | prepend: "/posts/" | append: "/" | relative_url %}
{% assign post_list = post_list | push: url %}
{% endfor %}