From 22115f37974da9b538d617d01085bec4be6b6d6d Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 15 Jul 2020 16:49:02 +0800 Subject: [PATCH] Optimized update list & fixed sw cache list. --- _includes/panel.html | 5 ----- _includes/update-list.html | 15 ++++++++++----- assets/js/data/cache-list.js | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/_includes/panel.html b/_includes/panel.html index 0a63a63..b70a9b2 100644 --- a/_includes/panel.html +++ b/_includes/panel.html @@ -28,12 +28,7 @@ {% if post %} {% assign url = post.url | relative_url %} -
  • {{ post.title }}
  • - - {% assign sum = sum | plus: 1 %} - {% if sum >= MAX_SIZE %} {% break %} {% endif %} - {% endif %} {% endfor %} diff --git a/_includes/update-list.html b/_includes/update-list.html index 9a66fea..231d9a0 100644 --- a/_includes/update-list.html +++ b/_includes/update-list.html @@ -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 %} diff --git a/assets/js/data/cache-list.js b/assets/js/data/cache-list.js index ab88073..8de9a3d 100644 --- a/assets/js/data/cache-list.js +++ b/assets/js/data/cache-list.js @@ -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 %}