jekyll-theme-chirpy 5.0.2 → 6.2.2

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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +64 -74
  3. data/_data/locales/ar.yml +91 -0
  4. data/_data/locales/bg-BG.yml +81 -0
  5. data/_data/locales/cs-CZ.yml +89 -0
  6. data/_data/locales/de-DE.yml +80 -0
  7. data/_data/locales/el-GR.yml +91 -0
  8. data/_data/locales/en.yml +23 -23
  9. data/_data/locales/es-ES.yml +77 -0
  10. data/_data/locales/fi-FI.yml +90 -0
  11. data/_data/locales/fr-FR.yml +77 -0
  12. data/_data/locales/hu-HU.yml +79 -0
  13. data/_data/locales/id-ID.yml +5 -19
  14. data/_data/locales/it-IT.yml +90 -0
  15. data/_data/locales/ko-KR.yml +12 -19
  16. data/_data/locales/my-MM.yml +77 -0
  17. data/_data/locales/pt-BR.yml +77 -0
  18. data/_data/locales/ru-RU.yml +77 -0
  19. data/_data/locales/sl-SI.yml +91 -0
  20. data/_data/locales/sv-SE.yml +91 -0
  21. data/_data/locales/th.yml +91 -0
  22. data/_data/locales/tr-TR.yml +77 -0
  23. data/_data/locales/uk-UA.yml +77 -0
  24. data/_data/locales/vi-VN.yml +76 -0
  25. data/_data/locales/zh-CN.yml +13 -20
  26. data/_data/locales/zh-TW.yml +83 -0
  27. data/_data/origin/basic.yml +48 -0
  28. data/_data/origin/cors.yml +59 -0
  29. data/_includes/comments/disqus.html +27 -31
  30. data/_includes/comments/giscus.html +64 -0
  31. data/_includes/comments/utterances.html +2 -2
  32. data/_includes/datetime.html +20 -0
  33. data/_includes/embed/twitch.html +4 -0
  34. data/_includes/embed/youtube.html +6 -0
  35. data/_includes/footer.html +31 -32
  36. data/_includes/head.html +66 -46
  37. data/_includes/js-selector.html +83 -45
  38. data/_includes/jsdelivr-combine.html +26 -0
  39. data/_includes/lang.html +1 -1
  40. data/_includes/mermaid.html +30 -29
  41. data/_includes/metadata-hook.html +1 -0
  42. data/_includes/mode-toggle.html +66 -51
  43. data/_includes/notification.html +24 -0
  44. data/_includes/origin-type.html +13 -0
  45. data/_includes/post-nav.html +26 -22
  46. data/_includes/post-paginator.html +79 -76
  47. data/_includes/post-sharing.html +27 -16
  48. data/_includes/read-time.html +17 -10
  49. data/_includes/refactor-content.html +129 -73
  50. data/_includes/related-posts.html +48 -58
  51. data/_includes/search-loader.html +32 -31
  52. data/_includes/search-results.html +4 -5
  53. data/_includes/sidebar.html +79 -67
  54. data/_includes/toc.html +4 -7
  55. data/_includes/topbar.html +62 -56
  56. data/_includes/trending-tags.html +15 -19
  57. data/_includes/update-list.html +14 -15
  58. data/_layouts/archives.html +25 -29
  59. data/_layouts/categories.html +97 -58
  60. data/_layouts/category.html +8 -10
  61. data/_layouts/default.html +67 -31
  62. data/_layouts/home.html +67 -56
  63. data/_layouts/page.html +20 -58
  64. data/_layouts/post.html +85 -94
  65. data/_layouts/tag.html +8 -10
  66. data/_layouts/tags.html +6 -5
  67. data/_sass/addon/commons.scss +679 -878
  68. data/_sass/addon/module.scss +70 -23
  69. data/_sass/addon/syntax.scss +127 -110
  70. data/_sass/addon/variables.scss +16 -18
  71. data/_sass/colors/syntax-dark.scss +138 -0
  72. data/_sass/colors/syntax-light.scss +179 -0
  73. data/_sass/colors/{dark-typography.scss → typography-dark.scss} +58 -56
  74. data/_sass/colors/typography-light.scss +110 -0
  75. data/_sass/layout/archives.scss +86 -89
  76. data/_sass/layout/categories.scss +29 -13
  77. data/_sass/layout/category-tag.scss +9 -10
  78. data/_sass/layout/home.scss +132 -114
  79. data/_sass/layout/post.scss +213 -173
  80. data/_sass/layout/tags.scss +1 -1
  81. data/_sass/main.scss +13 -0
  82. data/assets/404.html +1 -20
  83. data/assets/css/jekyll-theme-chirpy.scss +6 -0
  84. data/assets/feed.xml +2 -2
  85. data/assets/js/data/search.json +8 -5
  86. data/assets/js/data/swcache.js +14 -29
  87. data/assets/js/dist/categories.min.js +2 -4
  88. data/assets/js/dist/commons.min.js +2 -4
  89. data/assets/js/dist/home.min.js +2 -4
  90. data/assets/js/dist/misc.min.js +4 -0
  91. data/assets/js/dist/page.min.js +2 -4
  92. data/assets/js/dist/post.min.js +2 -4
  93. data/assets/js/pwa/app.js +42 -4
  94. data/assets/js/pwa/sw.js +46 -44
  95. data/assets/js/pwa/unregister.js +12 -0
  96. metadata +64 -32
  97. data/_config.yml +0 -175
  98. data/_data/contact.yml +0 -30
  99. data/_data/share.yml +0 -27
  100. data/_includes/css-selector.html +0 -15
  101. data/_includes/no-zero-date.html +0 -13
  102. data/_includes/timeago.html +0 -26
  103. data/_plugins/posts-lastmod-hook.rb +0 -14
  104. data/_sass/colors/dark-syntax.scss +0 -87
  105. data/_sass/colors/light-syntax.scss +0 -79
  106. data/_sass/colors/light-typography.scss +0 -81
  107. data/_sass/jekyll-theme-chirpy.scss +0 -24
  108. data/_tabs/about.md +0 -8
  109. data/_tabs/archives.md +0 -7
  110. data/_tabs/categories.md +0 -6
  111. data/_tabs/tags.md +0 -6
  112. data/assets/css/style.scss +0 -12
  113. data/assets/js/dist/pvreport.min.js +0 -6
  114. data/index.html +0 -4
@@ -1,88 +1,91 @@
1
- <!--
2
- The paginator for post list on HomgPage.
3
- -->
1
+ <!-- The paginator for post list on HomgPage. -->
4
2
 
5
- <ul class="pagination align-items-center mt-4 mb-0 pl-lg-2">
6
- <!-- left arrow -->
7
- {% if paginator.previous_page %}
8
- {% assign prev_url = paginator.previous_page_path | relative_url %}
9
- {% else %}
10
- {% assign prev_url = "#" %}
11
- {% endif %}
12
-
13
- <li class="page-item {% unless paginator.previous_page %}disabled{% endunless %}">
14
- <a class="page-link btn-box-shadow" href="{{ prev_url }}" aria-label="previous-page">
15
- <i class="fas fa-angle-left"></i>
16
- </a>
17
- </li>
3
+ <nav aria-label="Page Navigation">
4
+ <ul class="pagination align-items-center mt-4 mb-0">
5
+ <!-- left arrow -->
6
+ {% if paginator.previous_page %}
7
+ {% assign prev_url = paginator.previous_page_path | relative_url %}
8
+ {% else %}
9
+ {% assign prev_url = '#' %}
10
+ {% endif %}
18
11
 
19
- <!-- page numbers -->
20
- {% assign left_ellipsis = false %}
21
- {% assign right_ellipsis = false %}
12
+ <li class="page-item {% unless paginator.previous_page %}disabled{% endunless %}">
13
+ <a class="page-link" href="{{ prev_url }}" aria-label="previous-page">
14
+ <i class="fas fa-angle-left"></i>
15
+ </a>
16
+ </li>
22
17
 
23
- {% for i in (1..paginator.total_pages) %}
18
+ <!-- page numbers -->
19
+ {% assign left_ellipsis = false %}
20
+ {% assign right_ellipsis = false %}
24
21
 
25
- {% assign pre = paginator.page | minus: 1 %}
26
- {% assign next = paginator.page | plus: 1 %}
27
- {% assign pre_less = pre | minus: 1 %}
28
- {% assign next_more = next | plus: 1 %}
29
- {% assign show = false %}
22
+ {% for i in (1..paginator.total_pages) %}
23
+ {% assign pre = paginator.page | minus: 1 %}
24
+ {% assign next = paginator.page | plus: 1 %}
25
+ {% assign pre_less = pre | minus: 1 %}
26
+ {% assign next_more = next | plus: 1 %}
27
+ {% assign show = false %}
30
28
 
31
- {% if paginator.page == 1 %}
32
- {% if i <= 3 or i == paginator.total_pages %}
33
- {% assign show = true %}
34
- {% endif %}
35
- {% elsif paginator.page == paginator.total_pages %}
36
- {% if i == 1 or i >= pre_less %}
37
- {% assign show = true %}
29
+ {% if paginator.page == 1 %}
30
+ {% if i <= 3 or i == paginator.total_pages %}
31
+ {% assign show = true %}
32
+ {% endif %}
33
+ {% elsif paginator.page == paginator.total_pages %}
34
+ {% if i == 1 or i >= pre_less %}
35
+ {% assign show = true %}
36
+ {% endif %}
37
+ {% else %}
38
+ {% if i == 1 or i == paginator.total_pages %}
39
+ {% assign show = true %}
40
+ {% elsif i >= pre and i <= next %}
41
+ {% assign show = true %}
42
+ {% endif %}
38
43
  {% endif %}
39
- {% else %}
40
- {% if i == 1 or i == paginator.total_pages%}
41
- {% assign show = true %}
42
- {% elsif i >= pre and i <= next %}
43
- {% assign show = true %}
44
- {% endif %}
45
- {% endif %}
46
44
 
47
- {% if show %}
48
- <!-- show number -->
49
- <li class="page-item {% if i == paginator.page %} active{% endif %}">
50
- <a class="page-link btn-box-shadow" href="{{ site.baseurl }}/{% if i > 1%}page{{ i }}/{% endif %}">{{ i }}</a>
51
- </li>
52
- {% else %}
53
- <!-- hide number -->
54
- {% if i < pre and left_ellipsis == false %}
55
- <li class="page-item disabled">
56
- <span class="page-link btn-box-shadow">...</span>
57
- </li>
58
- {% assign left_ellipsis = true %}
59
- {% elsif i > next and right_ellipsis == false %}
60
- <li class="page-item disabled">
61
- <span class="page-link btn-box-shadow">...</span>
45
+ {% if show %}
46
+ <!-- show number -->
47
+ <li class="page-item {% if i == paginator.page %} active{% endif %}">
48
+ <a
49
+ class="page-link"
50
+ href="{% if i > 1 %}{{ site.paginate_path | replace: ':num', i | relative_url }}{% else %}{{ '/' | relative_url }}{% endif %}"
51
+ >
52
+ {{- i -}}
53
+ </a>
62
54
  </li>
63
- {% assign right_ellipsis = true %}
55
+ {% else %}
56
+ <!-- hide number -->
57
+ {% if i < pre and left_ellipsis == false %}
58
+ <li class="page-item disabled">
59
+ <span class="page-link">...</span>
60
+ </li>
61
+ {% assign left_ellipsis = true %}
62
+ {% elsif i > next and right_ellipsis == false %}
63
+ <li class="page-item disabled">
64
+ <span class="page-link">...</span>
65
+ </li>
66
+ {% assign right_ellipsis = true %}
67
+ {% endif %}
64
68
  {% endif %}
65
- {% endif %}
66
-
67
- {% endfor %}
69
+ {% endfor %}
68
70
 
69
- <!-- mobile pagination -->
70
- <li class="page-index align-middle">
71
- <span>{{ paginator.page }}</span>
72
- <span class="text-muted">/ {{ paginator.total_pages }}</span>
73
- </li>
71
+ <!-- mobile pagination -->
72
+ <li class="page-index align-middle">
73
+ <span>{{ paginator.page }}</span>
74
+ <span class="text-muted">/ {{ paginator.total_pages }}</span>
75
+ </li>
74
76
 
75
- <!-- right arrow -->
76
- {% if paginator.next_page_path %}
77
- {% assign next_url = paginator.next_page_path | relative_url %}
78
- {% else %}
79
- {% assign next_url = "#" %}
80
- {% endif %}
81
-
82
- <li class="page-item {% unless paginator.next_page_path %}disabled{% endunless %}">
83
- <a class="page-link btn-box-shadow" href="{{ next_url }}" aria-label="next-page">
84
- <i class="fas fa-angle-right"></i>
85
- </a>
86
- </li>
77
+ <!-- right arrow -->
78
+ {% if paginator.next_page_path %}
79
+ {% assign next_url = paginator.next_page_path | relative_url %}
80
+ {% else %}
81
+ {% assign next_url = '#' %}
82
+ {% endif %}
87
83
 
88
- </ul> <!-- .pagination -->
84
+ <li class="page-item {% unless paginator.next_page_path %}disabled{% endunless %}">
85
+ <a class="page-link" href="{{ next_url }}" aria-label="next-page">
86
+ <i class="fas fa-angle-right"></i>
87
+ </a>
88
+ </li>
89
+ </ul>
90
+ </nav>
91
+ <!-- .pagination -->
@@ -1,26 +1,37 @@
1
- <!--
2
- Post sharing snippet
3
- -->
1
+ <!-- Post sharing snippet -->
4
2
 
5
- <div class="share-wrapper">
6
- <span class="share-label text-muted mr-1">{{ site.data.locales[lang].post.share }}</span>
3
+ <div class="share-wrapper d-flex align-items-center">
4
+ <span class="share-label text-muted me-1">{{ site.data.locales[include.lang].post.share }}</span>
7
5
  <span class="share-icons">
8
6
  {% capture title %}{{ page.title }} - {{ site.title }}{% endcapture %}
9
- {% assign url = page.url | absolute_url %}
7
+ {% assign title = title | uri_escape %}
8
+ {% assign url = page.url | absolute_url | url_encode %}
10
9
 
11
10
  {% for share in site.data.share.platforms %}
12
11
  {% assign link = share.link | replace: 'TITLE', title | replace: 'URL', url %}
13
- <a href="{{ link }}" data-toggle="tooltip" data-placement="top"
14
- title="{{ share.type }}" target="_blank" rel="noopener" aria-label="{{ share.type }}">
15
- <i class="fa-fw {{ share.icon }}"></i>
16
- </a>
12
+ <a
13
+ href="{{ link }}"
14
+ data-bs-toggle="tooltip"
15
+ data-bs-placement="top"
16
+ title="{{ share.type }}"
17
+ target="_blank"
18
+ rel="noopener"
19
+ aria-label="{{ share.type }}"
20
+ >
21
+ <i class="fa-fw {{ share.icon }}"></i>
22
+ </a>
17
23
  {% endfor %}
18
24
 
19
- <i id="copy-link" class="fa-fw fas fa-link small"
20
- data-toggle="tooltip" data-placement="top"
21
- title="{{ site.data.locales[lang].post.button.share_link.title }}"
22
- title-succeed="{{ site.data.locales[lang].post.button.share_link.succeed }}">
23
- </i>
24
-
25
+ <button
26
+ id="copy-link"
27
+ aria-label="Copy link"
28
+ class="btn small"
29
+ data-bs-toggle="tooltip"
30
+ data-bs-placement="top"
31
+ title="{{ site.data.locales[include.lang].post.button.share_link.title }}"
32
+ data-title-succeed="{{ site.data.locales[include.lang].post.button.share_link.succeed }}"
33
+ >
34
+ <i class="fa-fw fas fa-link pe-none"></i>
35
+ </button>
25
36
  </span>
26
37
  </div>
@@ -1,10 +1,8 @@
1
- <!--
2
- Calculate the post's reading time, and display the word count in tooltip
3
- -->
1
+ <!-- Calculate the post's reading time, and display the word count in tooltip -->
4
2
 
5
- {% assign words = include.content | strip_html | number_of_words: "auto" %}
3
+ {% assign words = include.content | strip_html | number_of_words: 'auto' %}
6
4
 
7
- <!-- words per minute -->
5
+ <!-- words per minute -->
8
6
 
9
7
  {% assign wpm = 180 %}
10
8
  {% assign min_time = 1 %}
@@ -16,15 +14,24 @@
16
14
  {% endunless %}
17
15
 
18
16
  {% capture read_prompt %}
19
- {{- site.data.locales[lang].post.read_time.prompt -}}
17
+ {{- site.data.locales[include.lang].post.read_time.prompt -}}
20
18
  {% endcapture %}
21
19
 
22
20
  <!-- return element -->
23
- <span class="readtime" data-toggle="tooltip" data-placement="bottom"
24
- title="{{ words }} {{ site.data.locales[lang].post.words }}">
25
- <em>{{- read_time -}}{{" "}}{{- site.data.locales[lang].post.read_time.unit -}}</em>
21
+ <span
22
+ class="readtime"
23
+ data-bs-toggle="tooltip"
24
+ data-bs-placement="bottom"
25
+ title="{{ words }} {{ site.data.locales[include.lang].post.words }}"
26
+ >
27
+ <em>
28
+ {{- read_time -}}
29
+ {{ ' ' }}
30
+ {{- site.data.locales[include.lang].post.read_time.unit -}}
31
+ </em>
26
32
  {%- if include.prompt -%}
27
33
  {%- assign _prompt_words = read_prompt | number_of_words: 'auto' -%}
28
- {%- unless _prompt_words > 1 -%}{{ " " }}{%- endunless -%}{{ read_prompt }}
34
+ {%- unless _prompt_words > 1 -%}{{ ' ' }}{%- endunless -%}
35
+ {{ read_prompt }}
29
36
  {%- endif -%}
30
37
  </span>
@@ -1,6 +1,4 @@
1
- <!--
2
- Refactor the HTML structure.
3
- -->
1
+ <!-- Refactor the HTML structure -->
4
2
 
5
3
  {% assign _content = include.content %}
6
4
 
@@ -9,10 +7,11 @@
9
7
  we suround the markdown table with `<div class="table-wrapper">` and `</div>`
10
8
  -->
11
9
 
12
- {% if _content contains '<table>' %}
10
+ {% if _content contains '<table' %}
13
11
  {% assign _content = _content
14
- | replace: '<table>', '<div class="table-wrapper"><table>'
12
+ | replace: '<table', '<div class="table-wrapper"><table'
15
13
  | replace: '</table>', '</table></div>'
14
+ | replace: '<code><div class="table-wrapper">', '<code>'
16
15
  | replace: '</table></div></code>', '</table></code>'
17
16
  %}
18
17
  {% endif %}
@@ -30,47 +29,71 @@
30
29
  %}
31
30
  {% endif %}
32
31
 
33
- <!-- Add attribute 'hide-bullet' to the checkbox list -->
34
-
35
- {% if _content contains '<li class="task-list-item"><' %}
32
+ <!-- Change the icon of checkbox -->
33
+ {% if _content contains '<input type="checkbox"' %}
36
34
  {% assign _content = _content
37
- | replace: '"task-list-item"><', '"task-list-item" hide-bullet><'
35
+ | replace:
36
+ '<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />',
37
+ '<i class="fas fa-check-circle fa-fw checked"></i>'
38
+ | replace:
39
+ '<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />',
40
+ '<i class="far fa-circle fa-fw"></i>'
38
41
  %}
39
42
  {% endif %}
40
43
 
41
44
  <!-- images -->
42
-
43
45
  {% assign IMG_TAG = '<img ' %}
44
46
 
45
47
  {% if _content contains IMG_TAG %}
46
48
  {% assign _img_content = nil %}
47
49
  {% assign _img_snippets = _content | split: IMG_TAG %}
48
50
 
51
+ <!-- CDN URL -->
52
+ {% if site.img_cdn %}
53
+ {% if site.img_cdn contains '//' %}
54
+ {% assign _path_prefix = site.img_cdn %}
55
+ {% else %}
56
+ {% assign _path_prefix = site.img_cdn | relative_url %}
57
+ {% endif %}
58
+ {% else %}
59
+ {% assign _path_prefix = site.baseurl %}
60
+ {% endif %}
61
+
62
+ <!-- Add image path -->
63
+ {% if page.img_path %}
64
+ {% assign _path = page.img_path | append: '/' | replace: '//', '/' %}
65
+ {% assign _path_prefix = _path_prefix | append: _path %}
66
+ {% endif %}
67
+
49
68
  {% for _img_snippet in _img_snippets %}
50
69
  {% if forloop.first %}
51
70
  {% assign _img_content = _img_snippet %}
52
71
  {% continue %}
53
72
  {% endif %}
54
73
 
55
- {% assign _width = nil %}
56
- {% assign _height = nil %}
57
- {% assign _src = nil %}
58
-
59
74
  {% assign _left = _img_snippet | split: '>' | first %}
60
75
  {% assign _right = _img_snippet | remove: _left %}
61
76
 
62
- {% assign _left = _left | remove: ' /' %}
63
- {% assign _left = _left | replace: ' w=', ' width=' | replace: ' h=', ' height=' %}
64
- {% assign _attrs = _left | split: ' ' %}
77
+ {% unless _left contains 'src=' %}
78
+ {% continue %}
79
+ {% endunless %}
80
+
81
+ {% assign _left = _left | remove: ' /' | replace: ' w=', ' width=' | replace: ' h=', ' height=' %}
82
+ {% assign _attrs = _left | split: '" ' %}
83
+
84
+ {% assign _width = nil %}
85
+ {% assign _height = nil %}
86
+ {% assign _lqip = nil %}
87
+ {% assign _class = nil %}
65
88
 
66
89
  {% for _attr in _attrs %}
67
- {% assign _pair = _attr | split: '=' %}
68
- {% if _pair.size < 2 %}
90
+ {% unless _attr contains '=' %}
69
91
  {% continue %}
70
- {% endif %}
92
+ {% endunless %}
71
93
 
94
+ {% assign _pair = _attr | split: '="' %}
72
95
  {% capture _key %}{{ _pair | first }}{% endcapture %}
73
- {% capture _value %}{{ _pair | last | replace: '"', '' }}{% endcapture %}
96
+ {% capture _value %}{{ _pair | last | remove: '"' }}{% endcapture %}
74
97
 
75
98
  {% case _key %}
76
99
  {% when 'width' %}
@@ -79,64 +102,99 @@
79
102
  {% assign _height = _value %}
80
103
  {% when 'src' %}
81
104
  {% assign _src = _value %}
105
+ {% when 'lqip' %}
106
+ {% assign _lqip = _value %}
107
+ {% when 'class' %}
108
+ {% assign _class = _value %}
82
109
  {% endcase %}
83
-
84
- {% if _width and _height and _src %}
85
- {% break %}
86
- {% endif %}
87
110
  {% endfor %}
88
111
 
89
- {% if _src %}
90
- {% unless _src contains '://' %}
91
-
92
- <!-- Add CDN URL -->
93
- {% if site.img_cdn %}
94
- {% assign _src_prefix = site.img_cdn %}
95
- {% else %}
96
- {% assign _src_prefix = site.baseurl %}
97
- {% endif %}
98
-
99
- <!-- Add image path -->
100
- {% if page.img_path %}
101
- {% assign _path = page.img_path %}
102
- {% assign last_char = _path | slice: -1 %}
103
-
104
- {% unless last_char == '/' %}
105
- {% assign _path = _path | append: '/' %}
106
- {% endunless %}
107
-
108
- {% assign _src_prefix = _src_prefix | append: _path %}
109
- {% endif %}
110
-
111
- {% assign _final_src = _src_prefix | append: _src %}
112
- {% assign _left = _left | replace: _src, _final_src %}
112
+ <!-- take out classes -->
113
+ {% if _class %}
114
+ {% capture _old_class %}class="{{ _class }}"{% endcapture %}
115
+ {% assign _left = _left | remove: _old_class %}
116
+ {% endif %}
113
117
 
118
+ {% assign _final_src = nil %}
119
+
120
+ {% unless _src contains '//' %}
121
+ {% assign _final_src = _path_prefix | append: _src %}
122
+ {% capture _src_from %}"{{ _src }}"{% endcapture %}
123
+ {% capture _src_to %}"{{ _final_src }}"{% endcapture %}
124
+ {% assign _left = _left | replace: _src_from, _src_to %}
125
+ {% endunless %}
126
+
127
+ {% if _lqip %}
128
+ {% unless _lqip contains ':' %}
129
+ {% assign _final_lqip = _path_prefix | append: _lqip %}
130
+ {% capture _lqip_from %}"{{ _lqip }}"{% endcapture %}
131
+ {% capture _lqip_to %}"{{ _final_lqip }}"{% endcapture %}
132
+ {% assign _left = _left | replace: _lqip_from, _lqip_to %}
114
133
  {% endunless %}
134
+ {% endif %}
115
135
 
116
- <!-- lazy-load images <https://github.com/ApoorvSaxena/lozad.js#usage> -->
117
-
118
- {% assign _left = _left | replace: 'src=', 'data-src=' %}
136
+ <!-- lazy-load images <https://github.com/aFarkas/lazysizes#readme> -->
137
+ {% assign _left = _left | replace: 'src=', 'data-src=' %}
138
+ {% if _left contains 'class=' %}
139
+ {% assign _left = _left | replace: 'class="', 'class="lazyload '%}
140
+ {% else %}
141
+ {% assign _left = _left | append: ' class="lazyload"' %}
142
+ {% endif %}
119
143
 
144
+ <!-- add image placeholder -->
145
+ {% if _lqip %}
146
+ {% assign _left = _left | replace: ' lqip=', ' data-lqip="true" src=' %}
147
+ {% else %}
148
+ {% if _width and _height %}
149
+ <!-- add SVG placehoder -->
150
+ {%- capture _svg -%}
151
+ src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{ _width }} {{ _height }}'%3E%3C/svg%3E"
152
+ {%- endcapture -%}
153
+ {% assign _left = _svg | append: ' ' | append: _left %}
154
+ {% assign _class = _class | append: ' shimmer' %}
155
+ {% endif %}
120
156
  {% endif %}
121
157
 
122
- <!-- Add SVG placehoder to prevent layout reflow -->
158
+ <!-- Bypass the HTML-proofer test -->
159
+ {% assign _left = _left | append: ' data-proofer-ignore' %}
123
160
 
124
- {% if _width and _height %}
125
- {%- capture _svg -%}
126
- src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{ _width }} {{ _height }}'%3E%3C/svg%3E"
161
+ {% if page.layout == 'home' %}
162
+ <!-- create the image wrapper -->
163
+ {%- capture _wrapper_start -%}
164
+ <div class="preview-img {{ _class | strip }}">
127
165
  {%- endcapture -%}
166
+ {% assign _img_content = _img_content | append: _wrapper_start %}
167
+ {% assign _right = _right | prepend: '></div' %}
128
168
 
129
- {% assign _left = _svg | append: ' ' | append: _left %}
169
+ {% else %}
170
+ <!-- make sure the `<img>` is wrapped by `<a>` -->
171
+ {% assign _parent = _right | slice: 1, 4 %}
172
+
173
+ {% if _parent == '</a>' %}
174
+ <!-- add class to exist <a> tag -->
175
+ {% assign _size = _img_content | size | minus: 1 %}
176
+ {% capture _class %}
177
+ class="img-link{% unless _lqip %} shimmer{% endunless %}"
178
+ {% endcapture %}
179
+ {% assign _img_content = _img_content | slice: 0, _size | append: _class | append: '>' %}
180
+ {% else %}
181
+ <!-- create the image wrapper -->
182
+ {%- capture _wrapper_start -%}
183
+ <a href="{{ _final_src | default: _src }}" class="popup img-link {{ _class }}">
184
+ {%- endcapture -%}
185
+ {% assign _img_content = _img_content | append: _wrapper_start %}
186
+ {% assign _right = _right | prepend: '></a' %}
187
+ {% endif %}
130
188
  {% endif %}
131
189
 
132
- <!-- Bypass the HTML-proofer test -->
133
- {% assign _left = _left | append: ' data-proofer-ignore' %}
134
-
135
- {% assign _img_content = _img_content | append: IMG_TAG | append: _left | append: _right %}
190
+ <!-- combine -->
191
+ {% assign _img_content = _img_content | append: debug | append: IMG_TAG | append: _left | append: _right %}
136
192
 
137
193
  {% endfor %}
138
194
 
139
- {% assign _content = _img_content %}
195
+ {% if _img_content %}
196
+ {% assign _content = _img_content %}
197
+ {% endif %}
140
198
 
141
199
  {% endif %}
142
200
 
@@ -157,22 +215,22 @@
157
215
 
158
216
  {% if _left contains 'file="' %}
159
217
  {% assign _label_text = _left | split: 'file="' | last | split: '"' | first %}
160
- {% assign _label_icon = 'far fa-file-code' %}
218
+ {% assign _label_icon = 'far fa-file-code fa-fw' %}
161
219
  {% else %}
162
220
  {% assign _lang = _left | split: 'language-' | last | split: ' ' | first %}
163
221
  {% capture _label_text %}{% include language-alias.html language=_lang %}{% endcapture %}
164
- {% assign _label_icon = 'fas fa-code small' %}
222
+ {% assign _label_icon = 'fas fa-code fa-fw small' %}
165
223
  {% endif %}
166
224
 
167
225
  {% capture _label %}
168
- <span label-text="{{ _label_text | strip }}"><i class="{{ _label_icon }}"></i></span>
226
+ <span data-label-text="{{ _label_text | strip }}"><i class="{{ _label_icon }}"></i></span>
169
227
  {% endcapture %}
170
228
 
171
229
  {% assign _new_content = _new_content | append: _snippet
172
230
  | append: '<div class="code-header">'
173
231
  | append: _label
174
- | append: '<button aria-label="copy" title-succeed="'
175
- | append: site.data.locales[lang].post.button.copy_code.succeed
232
+ | append: '<button aria-label="copy" data-title-succeed="'
233
+ | append: site.data.locales[include.lang].post.button.copy_code.succeed
176
234
  | append: '"><i class="far fa-clipboard"></i></button></div>'
177
235
  | append: '<div class="highlight"><code>'
178
236
  %}
@@ -205,15 +263,14 @@
205
263
  {% endif %}
206
264
 
207
265
  {% assign id = snippet | split: '"' | first %}
208
- {% capture anchor %}<a href="#{{ id }}" class="anchor"><i class="fas fa-hashtag"></i></a>{% endcapture %}
266
+ {% capture anchor %}<a href="#{{ id }}" class="anchor text-muted"><i class="fas fa-hashtag"></i></a>{% endcapture %}
209
267
 
210
268
  {% assign left = snippet | split: mark_end | first %}
211
- {% assign _start_index = left | size %}
212
- {% assign _end_index = snippet | size | minus: 1 %}
213
- {% assign right = snippet | slice: _start_index, _end_index %}
269
+ {% assign right = snippet | slice: left.size, snippet.size %}
270
+ {% assign left = left | replace_first: '">', '"><span class="me-2">' | append: '</span>' %}
214
271
 
215
272
  {% assign _new_content = _new_content | append: mark_start
216
- | append: left | append: anchor | append: mark_end | append: right
273
+ | append: left | append: anchor | append: right
217
274
  %}
218
275
 
219
276
  {% endfor %}
@@ -226,5 +283,4 @@
226
283
  {% assign _content = _heading_content %}
227
284
 
228
285
  <!-- return -->
229
-
230
286
  {{ _content }}