jekyll-theme-chirpy 6.4.2 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 801a147b1a5aec791ce6f4c403e4d6fb8aff76c8dc6d616c2d858dbd8631c8b4
4
- data.tar.gz: 076fe2a85ef7057fa3aa88121906a83c325debdc4ea5dd3ed70ac440b4fa8fdc
3
+ metadata.gz: 5d87bca91299063e3d87743b6356009a2fe1ad90e235dc5af418ee959e75f128
4
+ data.tar.gz: 5e097d43490fe62782393123d8495d5bc5c5373af8cbb32793f136c8d56e5dc5
5
5
  SHA512:
6
- metadata.gz: 9d420b8ceda4fd78b62738985055e86b8d13d84b3f377af0f4f3bf3d22c3f30e83c62a892a1741fb86fc32124fd1392c611a7820f2ffe21f81186729f58cbe1a
7
- data.tar.gz: c6f736ff4cab1a279c640dab62dc8296a5bdefc245ad1cbf9f35d1bed066a394d69edbced8c1313650bb9a14ba0bdf13c0ee31b9e179f896f677ee310d8b18c4
6
+ metadata.gz: 7f483adc704ba4d46403d3bff07d53ff2614d1950e9ba421b58a566a08116d1fe6b64f75d93ff559261955f64e2aea16a9e79f05c4bebf82b2f9a869faf4e78a
7
+ data.tar.gz: 665126808c3a2736ace62f06105747ca0444a4716aa7cd69e8b5a071083e803c194342c9feda38b5bded34f1ea838a6fc1b925d2baf9cba384e9410238b1d091
data/README.md CHANGED
@@ -34,7 +34,7 @@
34
34
  - Built-in Search
35
35
  - Atom Feeds
36
36
  - PWA
37
- - Google Analytics
37
+ - Google Analytics / GoatCounter
38
38
  - SEO & Performance Optimization
39
39
 
40
40
  ## Documentation
@@ -8,6 +8,8 @@ cdns:
8
8
  - url: https://fonts.googleapis.com
9
9
  # jsDelivr CDN
10
10
  - url: https://cdn.jsdelivr.net
11
+ # polyfill.io for math
12
+ - url: https://polyfill.io
11
13
 
12
14
  # fonts
13
15
 
@@ -33,7 +35,7 @@ search:
33
35
  js: https://cdn.jsdelivr.net/npm/simple-jekyll-search@1.10.0/dest/simple-jekyll-search.min.js
34
36
 
35
37
  mermaid:
36
- js: https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js
38
+ js: https://cdn.jsdelivr.net/npm/mermaid@10.8.0/dist/mermaid.min.js
37
39
 
38
40
  dayjs:
39
41
  js:
@@ -8,7 +8,9 @@
8
8
  <link rel="apple-touch-icon" sizes="180x180" href="{{ favicon_path }}/apple-touch-icon.png">
9
9
  <link rel="icon" type="image/png" sizes="32x32" href="{{ favicon_path }}/favicon-32x32.png">
10
10
  <link rel="icon" type="image/png" sizes="16x16" href="{{ favicon_path }}/favicon-16x16.png">
11
- <link rel="manifest" href="{{ favicon_path }}/site.webmanifest">
11
+ {% if site.pwa.enabled %}
12
+ <link rel="manifest" href="{{ favicon_path }}/site.webmanifest">
13
+ {% endif %}
12
14
  <link rel="shortcut icon" href="{{ favicon_path }}/favicon.ico">
13
15
  <meta name="apple-mobile-web-app-title" content="{{ site.title }}">
14
16
  <meta name="application-name" content="{{ site.title }}">
@@ -8,9 +8,15 @@
8
8
  "
9
9
  >
10
10
  <p>
11
- {{ '©' }}
11
+ {{- '©' }}
12
12
  <time>{{ 'now' | date: '%Y' }}</time>
13
- <a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>.
13
+
14
+ {% if site.social.links %}
15
+ <a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>.
16
+ {% else %}
17
+ <em class="fst-normal">{{ site.social.name }}</em>.
18
+ {% endif %}
19
+
14
20
  {% if site.data.locales[include.lang].copyright.brief %}
15
21
  <span
16
22
  data-bs-toggle="tooltip"
@@ -0,0 +1,8 @@
1
+ <!-- GoatCounter -->
2
+
3
+ <script
4
+ data-goatcounter="https://{{ site.goatcounter.id }}.goatcounter.com/count"
5
+ async
6
+ src="https://gc.zgo.at/count.js"
7
+ ></script>
8
+
data/_includes/head.html CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  {% unless src contains '://' %}
22
22
  {%- capture img_url -%}
23
- {% include img-url.html src=src img_path=page.img_path %}
23
+ {% include img-url.html src=src img_path=page.img_path absolute=true %}
24
24
  {%- endcapture -%}
25
25
 
26
26
  {%- capture old_url -%}{{ src | absolute_url }}{%- endcapture -%}
@@ -31,15 +31,20 @@
31
31
 
32
32
  {% elsif site.social_preview_image %}
33
33
  {%- capture img_url -%}
34
- {% include img-url.html src=site.social_preview_image %}
34
+ {% include img-url.html src=site.social_preview_image absolute=true %}
35
35
  {%- endcapture -%}
36
36
 
37
37
  {%- capture og_image -%}
38
38
  <meta property="og:image" content="{{ img_url }}" />
39
39
  {%- endcapture -%}
40
40
 
41
- {% assign old_meta_clip = '<meta name="twitter:card"' %}
42
- {% assign new_meta_clip = og_image | append: old_meta_clip %}
41
+ {%- capture twitter_image -%}
42
+ <meta property="twitter:card" content="summary_large_image" />
43
+ <meta property="twitter:image" content="{{ img_url }}" />
44
+ {%- endcapture -%}
45
+
46
+ {% assign old_meta_clip = '<meta name="twitter:card" content="summary" />' %}
47
+ {% assign new_meta_clip = og_image | append: twitter_image %}
43
48
  {% assign seo_tags = seo_tags | replace: old_meta_clip, new_meta_clip %}
44
49
  {% endif %}
45
50
 
@@ -76,7 +81,7 @@
76
81
  {% endif %}
77
82
 
78
83
  <!-- Bootstrap -->
79
- <link rel="stylesheet" href="{{ site.data.origin[type].bootstrap.css | relative_url}}">
84
+ <link rel="stylesheet" href="{{ site.data.origin[type].bootstrap.css | relative_url }}">
80
85
 
81
86
  <!-- Font Awesome -->
82
87
  <link rel="stylesheet" href="{{ site.data.origin[type].fontawesome.css | relative_url }}">
@@ -2,8 +2,9 @@
2
2
  Generate image final URL based on `site.img_cdn`, `page.img_path`
3
3
 
4
4
  Arguments:
5
- src - basic image path, required
6
- img_path - relative path of image, optional
5
+ src - required, basic image path
6
+ img_path - optional, relative path of image
7
+ absolute - optional, boolean, if true, generate absolute URL
7
8
 
8
9
  Return:
9
10
  image URL
@@ -14,7 +15,7 @@
14
15
  {%- if url -%}
15
16
  {% unless url contains ':' %}
16
17
  {%- comment -%} CND URL {%- endcomment -%}
17
- {% assign prefix = site.img_cdn | default: '' | relative_url %}
18
+ {% assign prefix = site.img_cdn | default: '' %}
18
19
 
19
20
  {%- comment -%} Add page image path prefix {%- endcomment -%}
20
21
  {% assign url = include.img_path | default: '' | append: '/' | append: url %}
@@ -26,6 +27,12 @@
26
27
  | replace: '//', '/'
27
28
  | replace: ':', ':/'
28
29
  %}
30
+
31
+ {% if include.absolute %}
32
+ {% assign url = url | absolute_url %}
33
+ {% else %}
34
+ {% assign url = url | relative_url %}
35
+ {% endif %}
29
36
  {% endunless %}
30
37
  {%- endif -%}
31
38
 
@@ -11,6 +11,8 @@
11
11
 
12
12
  <!-- layout specified -->
13
13
 
14
+ {% assign js_dist = '/assets/js/dist/' %}
15
+
14
16
  {% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %}
15
17
  {% assign urls = urls | append: ',' | append: site.data.origin[type]['lazy-polyfill'].js %}
16
18
 
@@ -65,7 +67,7 @@
65
67
  {% assign js = 'commons' %}
66
68
  {% endcase %}
67
69
 
68
- {% capture script %}/assets/js/dist/{{ js }}.min.js{% endcapture %}
70
+ {% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %}
69
71
  <script defer src="{{ script | relative_url }}"></script>
70
72
 
71
73
  {% if page.math %}
@@ -83,7 +85,9 @@
83
85
  displayMath: [
84
86
  ['$$', '$$'],
85
87
  ['\\[', '\\]']
86
- ]
88
+ ],
89
+ /* equation numbering */
90
+ tags: 'ams'
87
91
  }
88
92
  };
89
93
  </script>
@@ -94,13 +98,16 @@
94
98
  {% if jekyll.environment == 'production' %}
95
99
  <!-- PWA -->
96
100
  {% if site.pwa.enabled %}
97
- <script defer src="{{ '/app.js' | relative_url }}"></script>
98
- {% else %}
99
- <script defer src="{{ '/unregister.js' | relative_url }}"></script>
101
+ <script defer src="{{ 'app.min.js' | prepend: js_dist | relative_url }}"></script>
100
102
  {% endif %}
101
103
 
102
104
  <!-- GA -->
103
105
  {% if site.google_analytics.id != empty and site.google_analytics.id %}
104
106
  {% include google-analytics.html %}
105
107
  {% endif %}
108
+
109
+ <!-- GoatCounter -->
110
+ {% if site.goatcounter.id != empty and site.goatcounter.id %}
111
+ {% include goatcounter.html %}
112
+ {% endif %}
106
113
  {% endif %}
@@ -17,7 +17,7 @@
17
17
  {% if forloop.first %}
18
18
  <span>
19
19
  <a href="{{ '/' | relative_url }}">
20
- {{ site.data.locales[include.lang].tabs.home | capitalize }}
20
+ {{- site.data.locales[include.lang].tabs.home | capitalize -}}
21
21
  </a>
22
22
  </span>
23
23
 
@@ -30,8 +30,8 @@
30
30
 
31
31
  {% elsif page.layout == 'category' or page.layout == 'tag' %}
32
32
  <span>
33
- <a href="{{ item | relative_url }}">
34
- {{ site.data.locales[include.lang].tabs[item] | default: page.title }}
33
+ <a href="{{ item | append: '/' | relative_url }}">
34
+ {{- site.data.locales[include.lang].tabs[item] | default: page.title -}}
35
35
  </a>
36
36
  </span>
37
37
  {% endif %}
@@ -144,6 +144,10 @@ footer {
144
144
  }
145
145
  }
146
146
 
147
+ em {
148
+ @extend %text-highlight;
149
+ }
150
+
147
151
  p {
148
152
  text-align: center;
149
153
  margin-bottom: 0;
@@ -0,0 +1,51 @@
1
+ ---
2
+ layout: compress
3
+ permalink: '/:path/swconf.js'
4
+ # Note that this file will be fetched by the ServiceWorker, so it will not be cached.
5
+ ---
6
+
7
+ const swconf = {
8
+ {% if site.pwa.cache.enabled %}
9
+ cacheName: 'chirpy-{{ "now" | date: "%s" }}',
10
+
11
+ {%- comment -%} Resources added to the cache during PWA installation. {%- endcomment -%}
12
+ resources: [
13
+ '{{ "/assets/css/:THEME.css" | replace: ':THEME', site.theme | relative_url }}',
14
+ '{{ "/" | relative_url }}',
15
+ {% for tab in site.tabs %}
16
+ '{{- tab.url | relative_url -}}',
17
+ {% endfor %}
18
+
19
+ {% assign cache_list = site.static_files | where: 'swcache', true %}
20
+ {% for file in cache_list %}
21
+ '{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
22
+ {% endfor %}
23
+ ],
24
+
25
+ {%- comment -%} The request url with below domain will be cached. {%- endcomment -%}
26
+ allowHosts: [
27
+ {% if site.img_cdn and site.img_cdn contains '//' %}
28
+ '{{ site.img_cdn | split: '//' | last | split: '/' | first }}',
29
+ {% endif %}
30
+
31
+ {%- unless site.assets.self_host.enabled -%}
32
+ {% for cdn in site.data.origin["cors"].cdns %}
33
+ '{{ cdn.url | split: "//" | last }}'
34
+ {%- unless forloop.last -%},{%- endunless -%}
35
+ {% endfor %}
36
+ {% endunless %}
37
+ ],
38
+
39
+ {%- comment -%} The request url with below path will not be cached. {%- endcomment -%}
40
+ denyPaths: [
41
+ {% for path in site.pwa.cache.deny_paths %}
42
+ {% unless path == empty %}
43
+ '{{ path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
44
+ {% endunless %}
45
+ {% endfor %}
46
+ ],
47
+ purge: false
48
+ {% else %}
49
+ purge: true
50
+ {% endif %}
51
+ };
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * Chirpy v6.4.2 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
2
+ * Chirpy v6.5.0 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
3
3
  */
4
4
  !function(){"use strict";const o=$(".mode-toggle");function t(o){var t=function(o,t){if("object"!=typeof o||!o)return o;var s=o[Symbol.toPrimitive];if(void 0!==s){var e=s.call(o,t||"default");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(o)}(o,"string");return"symbol"==typeof t?t:String(t)}function s(o,s,e){return(s=t(s))in o?Object.defineProperty(o,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[s]=e,o}const e=$("body"),a="sidebar-display";class r{static toggle(){!1===r.isExpanded?e.attr(a,""):e.removeAttr(a),r.isExpanded=!r.isExpanded}}s(r,"isExpanded",!1);const l=$("#sidebar-trigger"),n=$("#search-trigger"),i=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),f=$("#topbar-title"),d=$("search"),u=$("#search-result-wrapper"),p=$("#search-results"),b=$("#search-input"),g=$("#search-hints"),m=$("html,body"),C="loaded",v="unloaded",h="input-focus",w="d-flex";class y{static on(){y.offset=window.scrollY,m.scrollTop(0)}static off(){m.scrollTop(y.offset)}}s(y,"offset",0),s(y,"resultVisible",!1);class k{static on(){l.addClass(v),f.addClass(v),n.addClass(v),d.addClass(w),i.addClass(C)}static off(){i.removeClass(C),d.removeClass(w),l.removeClass(v),f.removeClass(v),n.removeClass(v)}}class T{static on(){y.resultVisible||(y.on(),u.removeClass(v),c.addClass(v),y.resultVisible=!0)}static off(){y.resultVisible&&(p.empty(),g.hasClass(v)&&g.removeClass(v),u.addClass(v),c.removeClass(v),y.off(),b.val(""),y.resultVisible=!1)}}function x(){return i.hasClass(C)}const E=$(".collapse");$(".code-header>button").children().attr("class"),function(){const o=$(window),t=$("#back-to-top");o.on("scroll",(()=>{o.scrollTop()>50?t.fadeIn():t.fadeOut()})),t.on("click",(()=>{o.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((o=>new bootstrap.Tooltip(o))),0!==o.length&&o.off().on("click",(o=>{const t=$(o.target);let s=t.prop("tagName")==="button".toUpperCase()?t:t.parent();modeToggle.flipMode(),s.trigger("blur")})),$("#sidebar-trigger").on("click",r.toggle),$("#mask").on("click",r.toggle),n.on("click",(function(){k.on(),T.on(),b.trigger("focus")})),i.on("click",(function(){k.off(),T.off()})),b.on("focus",(function(){d.addClass(h)})),b.on("focusout",(function(){d.removeClass(h)})),b.on("input",(()=>{""===b.val()?x()?g.removeClass(v):T.off():(T.on(),x()&&g.addClass(v))})),E.on("hide.bs.collapse",(function(){const o="h_"+$(this).attr("id").substring(2);o&&($("#".concat(o," .far.fa-folder-open")).attr("class","far fa-folder fa-fw"),$("#".concat(o," i.fas")).addClass("rotate"),$("#".concat(o)).removeClass("hide-border-bottom"))})),E.on("show.bs.collapse",(function(){const o="h_"+$(this).attr("id").substring(2);o&&($("#".concat(o," .far.fa-folder")).attr("class","far fa-folder-open fa-fw"),$("#".concat(o," i.fas")).removeClass("rotate"),$("#".concat(o)).addClass("hide-border-bottom"))}))}();
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * Chirpy v6.4.2 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
2
+ * Chirpy v6.5.0 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
3
3
  */
4
4
  !function(){"use strict";const e=$(".mode-toggle");function s(e){var s=function(e,s){if("object"!=typeof e||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var t=o.call(e,s||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===s?String:Number)(e)}(e,"string");return"symbol"==typeof s?s:String(s)}function o(e,o,t){return(o=s(o))in e?Object.defineProperty(e,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[o]=t,e}const t=$("body"),r="sidebar-display";class a{static toggle(){!1===a.isExpanded?t.attr(r,""):t.removeAttr(r),a.isExpanded=!a.isExpanded}}o(a,"isExpanded",!1);const l=$("#sidebar-trigger"),i=$("#search-trigger"),n=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),d=$("#topbar-title"),f=$("search"),u=$("#search-result-wrapper"),p=$("#search-results"),g=$("#search-input"),m=$("#search-hints"),b=$("html,body"),v="loaded",C="unloaded",h="input-focus",y="d-flex";class w{static on(){w.offset=window.scrollY,b.scrollTop(0)}static off(){b.scrollTop(w.offset)}}o(w,"offset",0),o(w,"resultVisible",!1);class k{static on(){l.addClass(C),d.addClass(C),i.addClass(C),f.addClass(y),n.addClass(v)}static off(){n.removeClass(v),f.removeClass(y),l.removeClass(C),d.removeClass(C),i.removeClass(C)}}class T{static on(){w.resultVisible||(w.on(),u.removeClass(C),c.addClass(C),w.resultVisible=!0)}static off(){w.resultVisible&&(p.empty(),m.hasClass(C)&&m.removeClass(C),u.addClass(C),c.removeClass(C),w.off(),g.val(""),w.resultVisible=!1)}}function x(){return n.hasClass(v)}!function(){const e=$(window),s=$("#back-to-top");e.on("scroll",(()=>{e.scrollTop()>50?s.fadeIn():s.fadeOut()})),s.on("click",(()=>{e.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((e=>new bootstrap.Tooltip(e))),0!==e.length&&e.off().on("click",(e=>{const s=$(e.target);let o=s.prop("tagName")==="button".toUpperCase()?s:s.parent();modeToggle.flipMode(),o.trigger("blur")})),$("#sidebar-trigger").on("click",a.toggle),$("#mask").on("click",a.toggle),i.on("click",(function(){k.on(),T.on(),g.trigger("focus")})),n.on("click",(function(){k.off(),T.off()})),g.on("focus",(function(){f.addClass(h)})),g.on("focusout",(function(){f.removeClass(h)})),g.on("input",(()=>{""===g.val()?x()?m.removeClass(C):T.off():(T.on(),x()&&m.addClass(C))}))}();
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * Chirpy v6.4.2 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
2
+ * Chirpy v6.5.0 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
3
3
  */
4
4
  !function(){"use strict";const t=$(".mode-toggle");function e(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var a=t[Symbol.toPrimitive];if(void 0!==a){var s=a.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function a(t,a,s){return(a=e(a))in t?Object.defineProperty(t,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[a]=s,t}const s=$("body"),o="sidebar-display";class r{static toggle(){!1===r.isExpanded?s.attr(o,""):s.removeAttr(o),r.isExpanded=!r.isExpanded}}a(r,"isExpanded",!1);const i=$("#sidebar-trigger"),l=$("#search-trigger"),n=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),d=$("#topbar-title"),u=$("search"),m=$("#search-result-wrapper"),f=$("#search-results"),p=$("#search-input"),g=$("#search-hints"),h=$("html,body"),b="loaded",v="unloaded",C="input-focus",y="d-flex";class w{static on(){w.offset=window.scrollY,h.scrollTop(0)}static off(){h.scrollTop(w.offset)}}a(w,"offset",0),a(w,"resultVisible",!1);class T{static on(){i.addClass(v),d.addClass(v),l.addClass(v),u.addClass(y),n.addClass(b)}static off(){n.removeClass(b),u.removeClass(y),i.removeClass(v),d.removeClass(v),l.removeClass(v)}}class k{static on(){w.resultVisible||(w.on(),m.removeClass(v),c.addClass(v),w.resultVisible=!0)}static off(){w.resultVisible&&(f.empty(),g.hasClass(v)&&g.removeClass(v),m.addClass(v),c.removeClass(v),w.off(),p.val(""),w.resultVisible=!1)}}function x(){return n.hasClass(b)}$(".collapse");$(".code-header>button").children().attr("class");const E="data-src",j="data-lqip",M={SHIMMER:"shimmer",BLUR:"blur"};function S(t){$(this).parent().removeClass(t)}function A(){this.complete&&(this.hasAttribute(j)?S.call(this,M.BLUR):S.call(this,M.SHIMMER))}function F(){const t=$(this),e=t.attr(E);t.attr("src",encodeURI(e)),t.removeAttr(E)}class R{static get attrTimestamp(){return"data-ts"}static get attrDateFormat(){return"data-df"}static get locale(){return $("html").attr("lang").substring(0,2)}static getTimestamp(t){return Number(t.attr(R.attrTimestamp))}static getDateFormat(t){return t.attr(R.attrDateFormat)}}!function(){const t=$(window),e=$("#back-to-top");t.on("scroll",(()=>{t.scrollTop()>50?e.fadeIn():e.fadeOut()})),e.on("click",(()=>{t.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((t=>new bootstrap.Tooltip(t))),0!==t.length&&t.off().on("click",(t=>{const e=$(t.target);let a=e.prop("tagName")==="button".toUpperCase()?e:e.parent();modeToggle.flipMode(),a.trigger("blur")})),$("#sidebar-trigger").on("click",r.toggle),$("#mask").on("click",r.toggle),l.on("click",(function(){T.on(),k.on(),p.trigger("focus")})),n.on("click",(function(){T.off(),k.off()})),p.on("focus",(function(){u.addClass(C)})),p.on("focusout",(function(){u.removeClass(C)})),p.on("input",(()=>{""===p.val()?x()?g.removeClass(v):k.off():(k.on(),x()&&g.addClass(v))})),dayjs.locale(R.locale),dayjs.extend(window.dayjs_plugin_localizedFormat),$("[".concat(R.attrTimestamp,"]")).each((function(){const t=dayjs.unix(R.getTimestamp($(this))),e=t.format(R.getDateFormat($(this)));$(this).text(e),$(this).removeAttr(R.attrTimestamp),$(this).removeAttr(R.attrDateFormat);const a=$(this).attr("data-bs-toggle");if(void 0===a||"tooltip"!==a)return;const s=t.format("llll");$(this).attr("data-bs-title",s),new bootstrap.Tooltip($(this))})),function(){const t=$("article img");t.length&&t.on("load",A),$('article img[loading="lazy"]').each((function(){this.complete&&S.call(this,M.SHIMMER)}));const e=$("article img[".concat(j,'="true"]'));e.length&&e.each(F)}()}();
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * Chirpy v6.4.2 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
2
+ * Chirpy v6.5.0 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
3
3
  */
4
4
  !function(){"use strict";const t=$(".mode-toggle");function e(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var a=t[Symbol.toPrimitive];if(void 0!==a){var s=a.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function a(t,a,s){return(a=e(a))in t?Object.defineProperty(t,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[a]=s,t}const s=$("body"),o="sidebar-display";class r{static toggle(){!1===r.isExpanded?s.attr(o,""):s.removeAttr(o),r.isExpanded=!r.isExpanded}}a(r,"isExpanded",!1);const l=$("#sidebar-trigger"),i=$("#search-trigger"),n=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),d=$("#topbar-title"),u=$("search"),f=$("#search-result-wrapper"),m=$("#search-results"),p=$("#search-input"),g=$("#search-hints"),b=$("html,body"),h="loaded",v="unloaded",C="input-focus",y="d-flex";class w{static on(){w.offset=window.scrollY,b.scrollTop(0)}static off(){b.scrollTop(w.offset)}}a(w,"offset",0),a(w,"resultVisible",!1);class T{static on(){l.addClass(v),d.addClass(v),i.addClass(v),u.addClass(y),n.addClass(h)}static off(){n.removeClass(h),u.removeClass(y),l.removeClass(v),d.removeClass(v),i.removeClass(v)}}class k{static on(){w.resultVisible||(w.on(),f.removeClass(v),c.addClass(v),w.resultVisible=!0)}static off(){w.resultVisible&&(m.empty(),g.hasClass(v)&&g.removeClass(v),f.addClass(v),c.removeClass(v),w.off(),p.val(""),w.resultVisible=!1)}}function x(){return n.hasClass(h)}$(".collapse");$(".code-header>button").children().attr("class");class j{static get attrTimestamp(){return"data-ts"}static get attrDateFormat(){return"data-df"}static get locale(){return $("html").attr("lang").substring(0,2)}static getTimestamp(t){return Number(t.attr(j.attrTimestamp))}static getDateFormat(t){return t.attr(j.attrDateFormat)}}!function(){const t=$(window),e=$("#back-to-top");t.on("scroll",(()=>{t.scrollTop()>50?e.fadeIn():e.fadeOut()})),e.on("click",(()=>{t.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((t=>new bootstrap.Tooltip(t))),0!==t.length&&t.off().on("click",(t=>{const e=$(t.target);let a=e.prop("tagName")==="button".toUpperCase()?e:e.parent();modeToggle.flipMode(),a.trigger("blur")})),$("#sidebar-trigger").on("click",r.toggle),$("#mask").on("click",r.toggle),i.on("click",(function(){T.on(),k.on(),p.trigger("focus")})),n.on("click",(function(){T.off(),k.off()})),p.on("focus",(function(){u.addClass(C)})),p.on("focusout",(function(){u.removeClass(C)})),p.on("input",(()=>{""===p.val()?x()?g.removeClass(v):k.off():(k.on(),x()&&g.addClass(v))})),dayjs.locale(j.locale),dayjs.extend(window.dayjs_plugin_localizedFormat),$("[".concat(j.attrTimestamp,"]")).each((function(){const t=dayjs.unix(j.getTimestamp($(this))),e=t.format(j.getDateFormat($(this)));$(this).text(e),$(this).removeAttr(j.attrTimestamp),$(this).removeAttr(j.attrDateFormat);const a=$(this).attr("data-bs-toggle");if(void 0===a||"tooltip"!==a)return;const s=t.format("llll");$(this).attr("data-bs-title",s),new bootstrap.Tooltip($(this))}))}();
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * Chirpy v6.4.2 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
2
+ * Chirpy v6.5.0 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
3
3
  */
4
4
  !function(){"use strict";const t=$(".mode-toggle");function e(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var s=o.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function o(t,o,s){return(o=e(o))in t?Object.defineProperty(t,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[o]=s,t}const s=$("body"),n="sidebar-display";class a{static toggle(){!1===a.isExpanded?s.attr(n,""):s.removeAttr(n),a.isExpanded=!a.isExpanded}}o(a,"isExpanded",!1);const r=$("#sidebar-trigger"),i=$("#search-trigger"),l=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),u=$("#topbar-title"),d=$("search"),f=$("#search-result-wrapper"),p=$("#search-results"),m=$("#search-input"),g=$("#search-hints"),h=$("html,body"),b="loaded",v="unloaded",C="input-focus",w="d-flex";class y{static on(){y.offset=window.scrollY,h.scrollTop(0)}static off(){h.scrollTop(y.offset)}}o(y,"offset",0),o(y,"resultVisible",!1);class k{static on(){r.addClass(v),u.addClass(v),i.addClass(v),d.addClass(w),l.addClass(b)}static off(){l.removeClass(b),d.removeClass(w),r.removeClass(v),u.removeClass(v),i.removeClass(v)}}class S{static on(){y.resultVisible||(y.on(),f.removeClass(v),c.addClass(v),y.resultVisible=!0)}static off(){y.resultVisible&&(p.empty(),g.hasClass(v)&&g.removeClass(v),f.addClass(v),c.removeClass(v),y.off(),m.val(""),y.resultVisible=!1)}}function T(){return l.hasClass(b)}$(".collapse");const E=".code-header>button",A="fas fa-check",x="timeout",M="data-title-succeed",R="data-bs-original-title",I=2e3;function V(t){if($(t)[0].hasAttribute(x)){let e=$(t).attr(x);if(Number(e)>Date.now())return!0}return!1}function q(t){$(t).attr(x,Date.now()+I)}function N(t){$(t).removeAttr(x)}const P=$(E).children().attr("class");const U="data-src",j="data-lqip",B={SHIMMER:"shimmer",BLUR:"blur"};function H(t){$(this).parent().removeClass(t)}function O(){this.complete&&(this.hasAttribute(j)?H.call(this,B.BLUR):H.call(this,B.SHIMMER))}function z(){const t=$(this),e=t.attr(U);t.attr("src",encodeURI(e)),t.removeAttr(U)}!function(){const t=$(window),e=$("#back-to-top");t.on("scroll",(()=>{t.scrollTop()>50?e.fadeIn():e.fadeOut()})),e.on("click",(()=>{t.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((t=>new bootstrap.Tooltip(t))),0!==t.length&&t.off().on("click",(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();modeToggle.flipMode(),o.trigger("blur")})),$("#sidebar-trigger").on("click",a.toggle),$("#mask").on("click",a.toggle),i.on("click",(function(){k.on(),S.on(),m.trigger("focus")})),l.on("click",(function(){k.off(),S.off()})),m.on("focus",(function(){d.addClass(C)})),m.on("focusout",(function(){d.removeClass(C)})),m.on("input",(()=>{""===m.val()?T()?g.removeClass(v):S.off():(S.on(),T()&&g.addClass(v))})),function(){const t=$("article img");t.length&&t.on("load",O),$('article img[loading="lazy"]').each((function(){this.complete&&H.call(this,B.SHIMMER)}));const e=$("article img[".concat(j,'="true"]'));e.length&&e.each(z)}(),$(".popup")<=0||$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),function(){if($(E).length){const t=new ClipboardJS(E,{target:t=>t.parentNode.nextElementSibling.querySelector("code .rouge-code")});[...document.querySelectorAll(E)].map((t=>new bootstrap.Tooltip(t,{placement:"left"}))),t.on("success",(t=>{t.clearSelection();const e=t.trigger;V(e)||(!function(t){$(t).children().attr("class",A)}(e),function(t){const e=$(t).attr(M);$(t).attr(R,e).tooltip("show")}(e),q(e),setTimeout((()=>{!function(t){$(t).tooltip("hide").removeAttr(R)}(e),function(t){$(t).children().attr("class",P)}(e),N(e)}),I))}))}const t=$("#copy-link");t.on("click",(t=>{let e=$(t.target);V(e)||navigator.clipboard.writeText(window.location.href).then((()=>{const t=e.attr(R),o=e.attr(M);e.attr(R,o).tooltip("show"),q(e),setTimeout((()=>{e.attr(R,t),N(e)}),I)}))})),t.on("mouseleave",(function(t){$(t.target).tooltip("hide")}))}()}();
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * Chirpy v6.4.2 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
2
+ * Chirpy v6.5.0 | © 2019 Cotes Chung | MIT Licensed | https://github.com/cotes2020/jekyll-theme-chirpy/
3
3
  */
4
- !function(){"use strict";const t=$(".mode-toggle");function e(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var a=o.call(t,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function o(t,o,a){return(o=e(o))in t?Object.defineProperty(t,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[o]=a,t}const a=$("body"),r="sidebar-display";class s{static toggle(){!1===s.isExpanded?a.attr(r,""):a.removeAttr(r),s.isExpanded=!s.isExpanded}}o(s,"isExpanded",!1);const i=$("#sidebar-trigger"),n=$("#search-trigger"),l=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),u=$("#topbar-title"),d=$("search"),m=$("#search-result-wrapper"),f=$("#search-results"),p=$("#search-input"),g=$("#search-hints"),h=$("html,body"),b="loaded",v="unloaded",C="input-focus",w="d-flex";class y{static on(){y.offset=window.scrollY,h.scrollTop(0)}static off(){h.scrollTop(y.offset)}}o(y,"offset",0),o(y,"resultVisible",!1);class S{static on(){i.addClass(v),u.addClass(v),n.addClass(v),d.addClass(w),l.addClass(b)}static off(){l.removeClass(b),d.removeClass(w),i.removeClass(v),u.removeClass(v),n.removeClass(v)}}class T{static on(){y.resultVisible||(y.on(),m.removeClass(v),c.addClass(v),y.resultVisible=!0)}static off(){y.resultVisible&&(f.empty(),g.hasClass(v)&&g.removeClass(v),m.addClass(v),c.removeClass(v),y.off(),p.val(""),y.resultVisible=!1)}}function k(){return l.hasClass(b)}$(".collapse");const x=".code-header>button",A="fas fa-check",E="timeout",j="data-title-succeed",D="data-bs-original-title",M=2e3;function F(t){if($(t)[0].hasAttribute(E)){let e=$(t).attr(E);if(Number(e)>Date.now())return!0}return!1}function R(t){$(t).attr(E,Date.now()+M)}function q(t){$(t).removeAttr(E)}const I=$(x).children().attr("class");const N="data-src",V="data-lqip",P={SHIMMER:"shimmer",BLUR:"blur"};function U(t){$(this).parent().removeClass(t)}function z(){this.complete&&(this.hasAttribute(V)?U.call(this,P.BLUR):U.call(this,P.SHIMMER))}function B(){const t=$(this),e=t.attr(N);t.attr("src",encodeURI(e)),t.removeAttr(N)}class H{static get attrTimestamp(){return"data-ts"}static get attrDateFormat(){return"data-df"}static get locale(){return $("html").attr("lang").substring(0,2)}static getTimestamp(t){return Number(t.attr(H.attrTimestamp))}static getDateFormat(t){return t.attr(H.attrDateFormat)}}0!==t.length&&t.off().on("click",(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();modeToggle.flipMode(),o.trigger("blur")})),$("#sidebar-trigger").on("click",s.toggle),$("#mask").on("click",s.toggle),n.on("click",(function(){S.on(),T.on(),p.trigger("focus")})),l.on("click",(function(){S.off(),T.off()})),p.on("focus",(function(){d.addClass(C)})),p.on("focusout",(function(){d.removeClass(C)})),p.on("input",(()=>{""===p.val()?k()?g.removeClass(v):T.off():(T.on(),k()&&g.addClass(v))})),function(){const t=$("article img");t.length&&t.on("load",z),$('article img[loading="lazy"]').each((function(){this.complete&&U.call(this,P.SHIMMER)}));const e=$("article img[".concat(V,'="true"]'));e.length&&e.each(B)}(),$(".popup")<=0||$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),dayjs.locale(H.locale),dayjs.extend(window.dayjs_plugin_localizedFormat),$("[".concat(H.attrTimestamp,"]")).each((function(){const t=dayjs.unix(H.getTimestamp($(this))),e=t.format(H.getDateFormat($(this)));$(this).text(e),$(this).removeAttr(H.attrTimestamp),$(this).removeAttr(H.attrDateFormat);const o=$(this).attr("data-bs-toggle");if(void 0===o||"tooltip"!==o)return;const a=t.format("llll");$(this).attr("data-bs-title",a),new bootstrap.Tooltip($(this))})),function(){if($(x).length){const t=new ClipboardJS(x,{target:t=>t.parentNode.nextElementSibling.querySelector("code .rouge-code")});[...document.querySelectorAll(x)].map((t=>new bootstrap.Tooltip(t,{placement:"left"}))),t.on("success",(t=>{t.clearSelection();const e=t.trigger;F(e)||(!function(t){$(t).children().attr("class",A)}(e),function(t){const e=$(t).attr(j);$(t).attr(D,e).tooltip("show")}(e),R(e),setTimeout((()=>{!function(t){$(t).tooltip("hide").removeAttr(D)}(e),function(t){$(t).children().attr("class",I)}(e),q(e)}),M))}))}const t=$("#copy-link");t.on("click",(t=>{let e=$(t.target);F(e)||navigator.clipboard.writeText(window.location.href).then((()=>{const t=e.attr(D),o=e.attr(j);e.attr(D,o).tooltip("show"),R(e),setTimeout((()=>{e.attr(D,t),q(e)}),M)}))})),t.on("mouseleave",(function(t){$(t.target).tooltip("hide")}))}(),document.querySelector("main h2")&&tocbot.init({tocSelector:"#toc",contentSelector:".content",ignoreSelector:"[data-toc-skip]",headingSelector:"h2, h3, h4",orderedList:!1,scrollSmooth:!1}),function(){const t=$(window),e=$("#back-to-top");t.on("scroll",(()=>{t.scrollTop()>50?e.fadeIn():e.fadeOut()})),e.on("click",(()=>{t.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((t=>new bootstrap.Tooltip(t)))}();
4
+ !function(){"use strict";const t=$(".mode-toggle");function e(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var a=o.call(t,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function o(t,o,a){return(o=e(o))in t?Object.defineProperty(t,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[o]=a,t}const a=$("body"),r="sidebar-display";class s{static toggle(){!1===s.isExpanded?a.attr(r,""):a.removeAttr(r),s.isExpanded=!s.isExpanded}}o(s,"isExpanded",!1);const i=$("#sidebar-trigger"),n=$("#search-trigger"),l=$("#search-cancel"),c=$("#main-wrapper>.container>.row"),u=$("#topbar-title"),d=$("search"),m=$("#search-result-wrapper"),f=$("#search-results"),p=$("#search-input"),g=$("#search-hints"),h=$("html,body"),b="loaded",v="unloaded",C="input-focus",w="d-flex";class y{static on(){y.offset=window.scrollY,h.scrollTop(0)}static off(){h.scrollTop(y.offset)}}o(y,"offset",0),o(y,"resultVisible",!1);class S{static on(){i.addClass(v),u.addClass(v),n.addClass(v),d.addClass(w),l.addClass(b)}static off(){l.removeClass(b),d.removeClass(w),i.removeClass(v),u.removeClass(v),n.removeClass(v)}}class T{static on(){y.resultVisible||(y.on(),m.removeClass(v),c.addClass(v),y.resultVisible=!0)}static off(){y.resultVisible&&(f.empty(),g.hasClass(v)&&g.removeClass(v),m.addClass(v),c.removeClass(v),y.off(),p.val(""),y.resultVisible=!1)}}function k(){return l.hasClass(b)}$(".collapse");const x=".code-header>button",A="fas fa-check",E="timeout",j="data-title-succeed",D="data-bs-original-title",M=2e3;function F(t){if($(t)[0].hasAttribute(E)){let e=$(t).attr(E);if(Number(e)>Date.now())return!0}return!1}function R(t){$(t).attr(E,Date.now()+M)}function q(t){$(t).removeAttr(E)}const I=$(x).children().attr("class");const N="data-src",V="data-lqip",P={SHIMMER:"shimmer",BLUR:"blur"};function U(t){$(this).parent().removeClass(t)}function z(){this.complete&&(this.hasAttribute(V)?U.call(this,P.BLUR):U.call(this,P.SHIMMER))}function B(){const t=$(this),e=t.attr(N);t.attr("src",encodeURI(e)),t.removeAttr(N)}class H{static get attrTimestamp(){return"data-ts"}static get attrDateFormat(){return"data-df"}static get locale(){return $("html").attr("lang").substring(0,2)}static getTimestamp(t){return Number(t.attr(H.attrTimestamp))}static getDateFormat(t){return t.attr(H.attrDateFormat)}}0!==t.length&&t.off().on("click",(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();modeToggle.flipMode(),o.trigger("blur")})),$("#sidebar-trigger").on("click",s.toggle),$("#mask").on("click",s.toggle),n.on("click",(function(){S.on(),T.on(),p.trigger("focus")})),l.on("click",(function(){S.off(),T.off()})),p.on("focus",(function(){d.addClass(C)})),p.on("focusout",(function(){d.removeClass(C)})),p.on("input",(()=>{""===p.val()?k()?g.removeClass(v):T.off():(T.on(),k()&&g.addClass(v))})),function(){const t=$("article img");t.length&&t.on("load",z),$('article img[loading="lazy"]').each((function(){this.complete&&U.call(this,P.SHIMMER)}));const e=$("article img[".concat(V,'="true"]'));e.length&&e.each(B)}(),$(".popup")<=0||$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),dayjs.locale(H.locale),dayjs.extend(window.dayjs_plugin_localizedFormat),$("[".concat(H.attrTimestamp,"]")).each((function(){const t=dayjs.unix(H.getTimestamp($(this))),e=t.format(H.getDateFormat($(this)));$(this).text(e),$(this).removeAttr(H.attrTimestamp),$(this).removeAttr(H.attrDateFormat);const o=$(this).attr("data-bs-toggle");if(void 0===o||"tooltip"!==o)return;const a=t.format("llll");$(this).attr("data-bs-title",a),new bootstrap.Tooltip($(this))})),function(){if($(x).length){const t=new ClipboardJS(x,{target:t=>t.parentNode.nextElementSibling.querySelector("code .rouge-code")});[...document.querySelectorAll(x)].map((t=>new bootstrap.Tooltip(t,{placement:"left"}))),t.on("success",(t=>{t.clearSelection();const e=t.trigger;F(e)||(!function(t){$(t).children().attr("class",A)}(e),function(t){const e=$(t).attr(j);$(t).attr(D,e).tooltip("show")}(e),R(e),setTimeout((()=>{!function(t){$(t).tooltip("hide").removeAttr(D)}(e),function(t){$(t).children().attr("class",I)}(e),q(e)}),M))}))}const t=$("#copy-link");t.on("click",(t=>{let e=$(t.target);F(e)||navigator.clipboard.writeText(window.location.href).then((()=>{const t=e.attr(D),o=e.attr(j);e.attr(D,o).tooltip("show"),R(e),setTimeout((()=>{e.attr(D,t),q(e)}),M)}))})),t.on("mouseleave",(function(t){$(t.target).tooltip("hide")}))}(),document.querySelector("main h2, main h3")&&tocbot.init({tocSelector:"#toc",contentSelector:".content",ignoreSelector:"[data-toc-skip]",headingSelector:"h2, h3, h4",orderedList:!1,scrollSmooth:!1}),function(){const t=$(window),e=$("#back-to-top");t.on("scroll",(()=>{t.scrollTop()>50?e.fadeIn():e.fadeOut()})),e.on("click",(()=>{t.scrollTop(0)}))}(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((t=>new bootstrap.Tooltip(t)))}();
data/assets/js/pwa/app.js CHANGED
@@ -1,47 +1,54 @@
1
1
  ---
2
2
  layout: compress
3
- permalink: '/app.js'
3
+ permalink: /assets/js/dist/:basename.min.js
4
4
  ---
5
5
 
6
- const $notification = $('#notification');
7
- const $btnRefresh = $('#notification .toast-body>button');
8
-
9
6
  if ('serviceWorker' in navigator) {
10
- /* Registering Service Worker */
11
- navigator.serviceWorker.register('{{ "/sw.js" | relative_url }}')
12
- .then(registration => {
13
-
14
- /* in case the user ignores the notification */
15
- if (registration.waiting) {
16
- $notification.toast('show');
7
+ const isEnabled = '{{ site.pwa.enabled }}' === 'true';
8
+
9
+ if (isEnabled) {
10
+ const swUrl = '{{ '/sw.min.js' | relative_url }}';
11
+ const $notification = $('#notification');
12
+ const $btnRefresh = $('#notification .toast-body>button');
13
+
14
+ navigator.serviceWorker.register(swUrl).then((registration) => {
15
+ {% comment %}In case the user ignores the notification{% endcomment %}
16
+ if (registration.waiting) {
17
+ $notification.toast('show');
18
+ }
19
+
20
+ registration.addEventListener('updatefound', () => {
21
+ registration.installing.addEventListener('statechange', () => {
22
+ if (registration.waiting) {
23
+ if (navigator.serviceWorker.controller) {
24
+ $notification.toast('show');
17
25
  }
18
-
19
- registration.addEventListener('updatefound', () => {
20
- registration.installing.addEventListener('statechange', () => {
21
- if (registration.waiting) {
22
- if (navigator.serviceWorker.controller) {
23
- $notification.toast('show');
24
- }
25
- }
26
- });
27
- });
28
-
29
- $btnRefresh.click(() => {
30
- if (registration.waiting) {
31
- registration.waiting.postMessage('SKIP_WAITING');
32
- }
33
- $notification.toast('hide');
34
- });
26
+ }
35
27
  });
28
+ });
29
+
30
+ $btnRefresh.on('click', () => {
31
+ if (registration.waiting) {
32
+ registration.waiting.postMessage('SKIP_WAITING');
33
+ }
34
+ $notification.toast('hide');
35
+ });
36
+ });
36
37
 
37
38
  let refreshing = false;
38
39
 
39
- /* Detect controller change and refresh all the opened tabs */
40
+ {% comment %}Detect controller change and refresh all the opened tabs{% endcomment %}
40
41
  navigator.serviceWorker.addEventListener('controllerchange', () => {
41
- if (!refreshing) {
42
- window.location.reload();
43
- refreshing = true;
44
- }
42
+ if (!refreshing) {
43
+ window.location.reload();
44
+ refreshing = true;
45
+ }
45
46
  });
47
+ } else {
48
+ navigator.serviceWorker.getRegistrations().then(function (registrations) {
49
+ for (let registration of registrations) {
50
+ registration.unregister();
51
+ }
52
+ });
53
+ }
46
54
  }
47
-
data/assets/js/pwa/sw.js CHANGED
@@ -1,37 +1,51 @@
1
1
  ---
2
2
  layout: compress
3
- permalink: '/sw.js'
3
+ permalink: /:basename.min.js
4
4
  # PWA service worker
5
5
  ---
6
6
 
7
- self.importScripts('{{ "/assets/js/data/swcache.js" | relative_url }}');
7
+ const swconfUrl = '{{ '/assets/js/data/swconf.js' | relative_url }}';
8
8
 
9
- const cacheName = 'chirpy-{{ "now" | date: "%s" }}';
9
+ importScripts(swconfUrl);
10
+ const purge = swconf.purge;
10
11
 
11
- function verifyDomain(url) {
12
- for (const domain of allowedDomains) {
13
- const regex = RegExp(`^http(s)?:\/\/${domain}\/`);
12
+ function verifyHost(url) {
13
+ for (const host of swconf.allowHosts) {
14
+ const regex = RegExp(`^http(s)?://${host}/`);
14
15
  if (regex.test(url)) {
15
16
  return true;
16
17
  }
17
18
  }
18
-
19
19
  return false;
20
20
  }
21
21
 
22
- function isExcluded(url) {
23
- for (const item of denyUrls) {
24
- if (url === item) {
25
- return true;
22
+ function verifyUrl(url) {
23
+ if (!verifyHost(url)) {
24
+ return false;
25
+ }
26
+
27
+ const requestPath = new URL(url).pathname;
28
+
29
+ for (const path of swconf.denyPaths) {
30
+ if (requestPath.startsWith(path)) {
31
+ return false;
26
32
  }
27
33
  }
28
- return false;
34
+ return true;
35
+ }
36
+
37
+ if (!purge) {
38
+ swconf.allowHosts.push(location.host);
29
39
  }
30
40
 
31
41
  self.addEventListener('install', (event) => {
42
+ if (purge) {
43
+ return;
44
+ }
45
+
32
46
  event.waitUntil(
33
- caches.open(cacheName).then((cache) => {
34
- return cache.addAll(resource);
47
+ caches.open(swconf.cacheName).then((cache) => {
48
+ return cache.addAll(swconf.resources);
35
49
  })
36
50
  );
37
51
  });
@@ -41,8 +55,12 @@ self.addEventListener('activate', (event) => {
41
55
  caches.keys().then((keyList) => {
42
56
  return Promise.all(
43
57
  keyList.map((key) => {
44
- if (key !== cacheName) {
58
+ if (purge) {
45
59
  return caches.delete(key);
60
+ } else {
61
+ if (key !== swconf.cacheName) {
62
+ return caches.delete(key);
63
+ }
46
64
  }
47
65
  })
48
66
  );
@@ -66,22 +84,16 @@ self.addEventListener('fetch', (event) => {
66
84
  return fetch(event.request).then((response) => {
67
85
  const url = event.request.url;
68
86
 
69
- if (
70
- event.request.method !== 'GET' ||
71
- !verifyDomain(url) ||
72
- isExcluded(url)
73
- ) {
87
+ if (purge || event.request.method !== 'GET' || !verifyUrl(url)) {
74
88
  return response;
75
89
  }
76
90
 
77
- /* see: <https://developers.google.com/web/fundamentals/primers/service-workers#cache_and_return_requests> */
91
+ {% comment %}See: <https://developers.google.com/web/fundamentals/primers/service-workers#cache_and_return_requests>{% endcomment %}
78
92
  let responseToCache = response.clone();
79
93
 
80
- caches.open(cacheName).then((cache) => {
81
- /* console.log('[sw] Caching new resource: ' + event.request.url); */
94
+ caches.open(swconf.cacheName).then((cache) => {
82
95
  cache.put(event.request, responseToCache);
83
96
  });
84
-
85
97
  return response;
86
98
  });
87
99
  })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-chirpy
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.2
4
+ version: 6.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cotes Chung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -153,6 +153,7 @@ files:
153
153
  - _includes/embed/youtube.html
154
154
  - _includes/favicons.html
155
155
  - _includes/footer.html
156
+ - _includes/goatcounter.html
156
157
  - _includes/google-analytics.html
157
158
  - _includes/head.html
158
159
  - _includes/img-url.html
@@ -218,7 +219,7 @@ files:
218
219
  - assets/img/favicons/mstile-150x150.png
219
220
  - assets/img/favicons/site.webmanifest
220
221
  - assets/js/data/search.json
221
- - assets/js/data/swcache.js
222
+ - assets/js/data/swconf.js
222
223
  - assets/js/dist/categories.min.js
223
224
  - assets/js/dist/commons.min.js
224
225
  - assets/js/dist/home.min.js
@@ -227,7 +228,6 @@ files:
227
228
  - assets/js/dist/post.min.js
228
229
  - assets/js/pwa/app.js
229
230
  - assets/js/pwa/sw.js
230
- - assets/js/pwa/unregister.js
231
231
  - assets/robots.txt
232
232
  homepage: https://github.com/cotes2020/jekyll-theme-chirpy
233
233
  licenses:
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  - !ruby/object:Gem::Version
255
255
  version: '0'
256
256
  requirements: []
257
- rubygems_version: 3.5.3
257
+ rubygems_version: 3.5.5
258
258
  signing_key:
259
259
  specification_version: 4
260
260
  summary: A minimal, responsive, and feature-rich Jekyll theme for technical writing.
@@ -1,49 +0,0 @@
1
- ---
2
- layout: compress
3
- # The list to be cached by PWA
4
- ---
5
-
6
- const resource = [
7
- /* --- CSS --- */
8
- '{{ "/assets/css/:THEME.css" | replace: ':THEME', site.theme | relative_url }}',
9
-
10
- /* --- PWA --- */
11
- '{{ "/app.js" | relative_url }}',
12
- '{{ "/sw.js" | relative_url }}',
13
-
14
- /* --- HTML --- */
15
- '{{ "/index.html" | relative_url }}',
16
- '{{ "/404.html" | relative_url }}',
17
-
18
- {% for tab in site.tabs %}
19
- '{{ tab.url | relative_url }}',
20
- {% endfor %}
21
-
22
- /* --- Favicons & compressed JS --- */
23
- {% assign cache_list = site.static_files | where: 'swcache', true %}
24
- {% for file in cache_list %}
25
- '{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
26
- {% endfor %}
27
- ];
28
-
29
- /* The request url with below domain will be cached */
30
- const allowedDomains = [
31
- {% if site.google_analytics.id != empty and site.google_analytics.id %}
32
- 'www.googletagmanager.com',
33
- 'www.google-analytics.com',
34
- {% endif %}
35
-
36
- '{{ site.url | split: "//" | last }}',
37
-
38
- {% if site.img_cdn contains '//' and site.img_cdn %}
39
- '{{ site.img_cdn | split: '//' | last | split: '/' | first }}',
40
- {% endif %}
41
-
42
- 'fonts.gstatic.com',
43
- 'fonts.googleapis.com',
44
- 'cdn.jsdelivr.net',
45
- 'polyfill.io'
46
- ];
47
-
48
- /* Requests that include the following path will be banned */
49
- const denyUrls = [];
@@ -1,12 +0,0 @@
1
- ---
2
- layout: compress
3
- permalink: '/unregister.js'
4
- ---
5
-
6
- if ('serviceWorker' in navigator) {
7
- navigator.serviceWorker.getRegistrations().then((registrations) => {
8
- for (let reg of registrations) {
9
- reg.unregister();
10
- }
11
- });
12
- }