1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 05:41:31 +00:00

New feature: PWA

This commit is contained in:
Cotes Chung
2020-05-10 00:28:18 +08:00
parent b64598358d
commit d8e45694bd
10 changed files with 266 additions and 66 deletions

View File

@@ -144,4 +144,7 @@
<script src="{{ site.baseurl }}/assets/js/dist/tooltip-loader.min.js" async></script>
<!-- PWA -->
<script src="{{ '/app.js' | relative_url }}" defer></script>
</head>

View File

@@ -11,20 +11,10 @@
<div class="access">
{% if site.data.updates %}
{% assign MAX_SIZE = 5 %}
{% assign sum = 0 %}
{% assign sort_list = "" | split: "" %}
{% for entry in site.data.updates %}
{% capture elem %}
{{- entry.lastmod -}}::{{- entry.filename -}}
{% endcapture %}
{% assign sort_list = sort_list | push: elem %}
{% endfor %}
{% include update_list.html %}
{% assign sort_list = sort_list | sort | reverse %}
{% if sort_list.size > 0 %}
{% if update_list.size > 0 %}
<div id="access-lastmod" class="post">
<h3 data-toc-skip>
@@ -32,7 +22,7 @@
</h3>
<ul class="post-content pl-0 pb-1 ml-1 mt-2">
{% for item in sort_list %}
{% for item in update_list %}
{% assign post_url = item | split: "::" | last | prepend: "/posts/" | append: "/" %}
{% assign post = site.posts | where: "url", post_url | first %}
@@ -60,7 +50,11 @@
{{- site.data.label.panel.trending_tags -}}
</h3>
<div class="d-flex flex-wrap mt-3 mb-1 mr-3">
{% include trending-tags.html %}
{% include trending-tags.html %}
{% for tag in trending_tags %}
{% capture url %}/tags/{{ tag | downcase | url_encode }}/{% endcapture %}
<a class="post-tag" href="{{ url | relative_url }}">{{ tag | replace: '-', ' ' }}</a>
{% endfor %}
</div>
</div>

View File

@@ -1,27 +1,31 @@
<!--
{% comment %}
The trending tags list
v2.0
https://github.com/cotes2020/jekyll-theme-chirpy
© 2019 Cotes Chung
MIT Licensed
-->
{% endcomment %}
{% assign MAX = 10 %}
{% capture tags_array %}
{% for tag in site.tags %}
{{ tag[1] | size }}:{{ tag[0] | replace: ' ', '-' }}
{{ tag[1] | size }}::{{ tag[0] | replace: ' ', '-' }}
{% endfor %}
{% endcapture %}
{% assign trends = tags_array | split: " " | sort | reverse %}
{% assign all_tags = tags_array | split: " " | sort | reverse %}
{% assign count = 0 %}
{% for trend in trends %}
{% assign trending_tags = "" | split: "" %}
{% for iter in all_tags %}
{% assign count = count | plus: 1 %}
{% assign tag = trend | split: ":" | last %}
<a class="post-tag" href="{{ site.baseurl }}/tags/{{ tag | downcase | url_encode }}/">{{ tag | replace: '-', ' ' }}</a>
{% assign tag = iter | split: "::" | last %}
{% assign trending_tags = trending_tags | push: tag %}
{% if count >= MAX %}
{% break %}
{% endif %}
{% endfor %}
{% endfor %}

View File

@@ -0,0 +1,21 @@
{% comment %}
Get the last 5 post from lastmod list.
v2.2
https://github.com/cotes2020/jekyll-theme-chirpy
© 2020 Cotes Chung
MIT License
{% endcomment %}
{% assign MAX_SIZE = 5 %}
{% assign sum = 0 %}
{% assign update_list = "" | split: "" %}
{% for entry in site.data.updates %}
{% capture elem %}
{{- entry.lastmod -}}::{{- entry.filename -}}
{% endcapture %}
{% assign update_list = update_list | push: elem %}
{% endfor %}
{% assign update_list = update_list | sort | reverse %}