Skip to content

Commit b69d3d7

Browse files
committed
refactor(build): modularize JS code
- replace gulp with rollup - remove JS output from repo
1 parent 002f025 commit b69d3d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1261
-1241
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ _site
1010
# RubyGems
1111
*.gem
1212

13-
# npm dependencies
13+
# NPM dependencies
1414
node_modules
1515
package-lock.json
1616

1717
# IDE configurations
1818
.idea
1919
.vscode
20+
21+
# Misc
22+
assets/js/dist

_config.yml

+37-38
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,59 @@ theme: jekyll-theme-chirpy
55

66
# Change the following value to '/PROJECT_NAME' ONLY IF your site type is GitHub Pages Project sites
77
# and doesn't have a custom domain.
8-
baseurl: ''
8+
baseurl: ""
99

1010
# The language of the webpage › http://www.lingoes.net/en/translator/langcode.htm
1111
# If it has the same name as one of the files in folder `_data/locales`, the layout language will also be changed,
1212
# otherwise, the layout language will use the default value of 'en'.
1313
lang: en
1414

15-
1615
# Change to your timezone › http://www.timezoneconverter.com/cgi-bin/findzone/findzone
1716
timezone: Asia/Shanghai
1817

1918
# jekyll-seo-tag settings › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/usage.md
2019
# ↓ --------------------------
2120

22-
title: Chirpy # the main title
21+
title: Chirpy # the main title
2322

24-
tagline: A text-focused Jekyll theme # it will display as the sub-title
23+
tagline: A text-focused Jekyll theme # it will display as the sub-title
2524

26-
description: >- # used by seo meta and the atom feed
25+
description: >- # used by seo meta and the atom feed
2726
A minimal, responsive and feature-rich Jekyll theme for technical writing.
2827
2928
# fill in the protocol & hostname for your site, e.g., 'https://username.github.io'
30-
url: ''
29+
url: ""
3130

3231
github:
33-
username: github_username # change to your github username
32+
username: github_username # change to your github username
3433

3534
twitter:
36-
username: twitter_username # change to your twitter username
35+
username: twitter_username # change to your twitter username
3736

3837
social:
3938
# Change to your full name.
4039
# It will be displayed as the default author of the posts and the copyright owner in the Footer
4140
name: your_full_name
42-
email: [email protected] # change to your email address
41+
email: [email protected] # change to your email address
4342
links:
4443
# The first element serves as the copyright owner's link
45-
- https://twitter.com/username # change to your twitter homepage
46-
- https://github.com/username # change to your github homepage
44+
- https://twitter.com/username # change to your twitter homepage
45+
- https://github.com/username # change to your github homepage
4746
# Uncomment below to add more social links
4847
# - https://www.facebook.com/username
4948
# - https://www.linkedin.com/in/username
5049

51-
google_site_verification: # fill in to your verification string
50+
google_site_verification: # fill in to your verification string
5251

5352
# ↑ --------------------------
5453
# The end of `jekyll-seo-tag` settings
5554

5655
google_analytics:
57-
id: # fill in your Google Analytics ID
56+
id: # fill in your Google Analytics ID
5857
# Google Analytics pageviews report settings
5958
pv:
60-
proxy_endpoint: # fill in the Google Analytics superProxy endpoint of Google App Engine
61-
cache_path: # the local PV cache data, friendly to visitors from GFW region
59+
proxy_endpoint: # fill in the Google Analytics superProxy endpoint of Google App Engine
60+
cache_path: # the local PV cache data, friendly to visitors from GFW region
6261

6362
# Prefer color scheme setting.
6463
#
@@ -71,59 +70,59 @@ google_analytics:
7170
# light - Use the light color scheme
7271
# dark - Use the dark color scheme
7372
#
74-
theme_mode: # [light|dark]
73+
theme_mode: # [light|dark]
7574

7675
# The CDN endpoint for images.
7776
# Notice that once it is assigned, the CDN url
7877
# will be added to all image (site avatar & posts' images) paths starting with '/'
7978
#
8079
# e.g. 'https://cdn.com'
81-
img_cdn: 'https://chirpy-img.netlify.app'
80+
img_cdn: "https://chirpy-img.netlify.app"
8281

8382
# the avatar on sidebar, support local or CORS resources
84-
avatar: '/commons/avatar.jpg'
83+
avatar: "/commons/avatar.jpg"
8584

8685
# boolean type, the global switch for ToC in posts.
8786
toc: true
8887

8988
comments:
90-
active: # The global switch for posts comments, e.g., 'disqus'. Keep it empty means disable
89+
active: # The global switch for posts comments, e.g., 'disqus'. Keep it empty means disable
9190
# The active options are as follows:
9291
disqus:
93-
shortname: # fill with the Disqus shortname. › https://help.disqus.com/en/articles/1717111-what-s-a-shortname
92+
shortname: # fill with the Disqus shortname. › https://help.disqus.com/en/articles/1717111-what-s-a-shortname
9493
# utterances settings › https://utteranc.es/
9594
utterances:
96-
repo: # <gh-username>/<repo>
97-
issue_term: # < url | pathname | title | ...>
95+
repo: # <gh-username>/<repo>
96+
issue_term: # < url | pathname | title | ...>
9897
# Giscus options › https://giscus.app
9998
giscus:
100-
repo: # <gh-username>/<repo>
99+
repo: # <gh-username>/<repo>
101100
repo_id:
102101
category:
103102
category_id:
104-
mapping: # optional, default to 'pathname'
105-
input_position: # optional, default to 'bottom'
106-
lang: # optional, default to the value of `site.lang`
103+
mapping: # optional, default to 'pathname'
104+
input_position: # optional, default to 'bottom'
105+
lang: # optional, default to the value of `site.lang`
107106
reactions_enabled: # optional, default to the value of `1`
108107

109108
# Self-hosted static assets, optional › https://github.com/cotes2020/chirpy-static-assets
110109
assets:
111110
self_host:
112-
enabled: # boolean, keep empty means false
111+
enabled: # boolean, keep empty means false
113112
# specify the Jekyll environment, empty means both
114113
# only works if `assets.self_host.enabled` is 'true'
115-
env: # [development|production]
114+
env: # [development|production]
116115

117116
pwa:
118-
enabled: true # the option for PWA feature
117+
enabled: true # the option for PWA feature
119118

120119
paginate: 10
121120

122121
# ------------ The following options are not recommended to be modified ------------------
123122

124123
kramdown:
125124
syntax_highlighter: rouge
126-
syntax_highlighter_opts: # Rouge Options › https://github.com/jneen/rouge#full-options
125+
syntax_highlighter_opts: # Rouge Options › https://github.com/jneen/rouge#full-options
127126
css_class: highlight
128127
# default_lang: console
129128
span:
@@ -139,12 +138,12 @@ collections:
139138

140139
defaults:
141140
- scope:
142-
path: '' # An empty string here means all files in the project
141+
path: "" # An empty string here means all files in the project
143142
type: posts
144143
values:
145144
layout: post
146-
comments: true # Enable comments in posts.
147-
toc: true # Display TOC column in posts.
145+
comments: true # Enable comments in posts.
146+
toc: true # Display TOC column in posts.
148147
# DO NOT modify the following parameter unless you are confident enough
149148
# to update the code of all other post links in this project.
150149
permalink: /posts/:title/
@@ -153,8 +152,8 @@ defaults:
153152
values:
154153
comments: false
155154
- scope:
156-
path: ''
157-
type: tabs # see `site.collections`
155+
path: ""
156+
type: tabs # see `site.collections`
158157
values:
159158
layout: page
160159
permalink: /:title/
@@ -180,13 +179,13 @@ compress_html:
180179
envs: [development]
181180

182181
exclude:
183-
- '*.gem'
184-
- '*.gemspec'
182+
- "*.gem"
183+
- "*.gemspec"
185184
- tools
186185
- README.md
187186
- CHANGELOG.md
188187
- LICENSE
189-
- gulpfile.js
188+
- rollup.config.js
190189
- node_modules
191190
- package*.json
192191

_includes/js-selector.html

+42-45
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,80 @@
1-
<!--
2-
JS selector for site.
3-
-->
1+
<!-- JS selector for site. -->
42

53
<!-- layout specified -->
64

75
{% if page.layout == 'post' %}
86
{% if site.google_analytics.pv.proxy_endpoint or site.google_analytics.pv.cache_path %}
97
<!-- pv-report needs countup.js -->
108
<script async src="{{ site.data.assets[origin].countup.js | relative_url }}"></script>
11-
<script defer src="{{ '/assets/js/dist/pvreport.min.js' | relative_url }}"></script>
129
{% endif %}
1310
{% endif %}
1411

1512
{% if page.layout == 'post' or page.layout == 'page' %}
1613
<!-- image lazy-loading & popup & clipboard -->
17-
{% assign _urls = site.data.assets[origin].magnific-popup.js
18-
| append: ',' | append: site.data.assets[origin].lazysizes.js
19-
| append: ',' | append: site.data.assets[origin].clipboard.js
14+
{% assign _urls = site.data.assets[origin]['magnific-popup'].js
15+
| append: ','
16+
| append: site.data.assets[origin].lazysizes.js
17+
| append: ','
18+
| append: site.data.assets[origin].clipboard.js
2019
%}
2120

2221
{% include jsdelivr-combine.html urls=_urls %}
2322
{% endif %}
2423

2524
{% if page.layout == 'home'
26-
or page.layout == 'post'
27-
or page.layout == 'archives'
28-
or page.layout == 'category'
29-
or page.layout == 'tag' %}
30-
25+
or page.layout == 'post'
26+
or page.layout == 'archives'
27+
or page.layout == 'category'
28+
or page.layout == 'tag'
29+
%}
3130
{% assign locale = site.lang | split: '-' | first %}
3231

3332
{% assign _urls = site.data.assets[origin].dayjs.js.common
34-
| append: ',' | append: site.data.assets[origin].dayjs.js.locale
35-
| replace: ':LOCALE', locale
36-
| append: ',' | append: site.data.assets[origin].dayjs.js.relativeTime
37-
| append: ',' | append: site.data.assets[origin].dayjs.js.localizedFormat
33+
| append: ','
34+
| append: site.data.assets[origin].dayjs.js.locale
35+
| replace: ':LOCALE', locale
36+
| append: ','
37+
| append: site.data.assets[origin].dayjs.js.relativeTime
38+
| append: ','
39+
| append: site.data.assets[origin].dayjs.js.localizedFormat
3840
%}
3941

4042
{% include jsdelivr-combine.html urls=_urls %}
41-
4243
{% endif %}
4344

44-
{% if page.layout == 'home'
45-
or page.layout == 'categories'
46-
or page.layout == 'post'
47-
or page.layout == 'page' %}
48-
{% assign type = page.layout %}
49-
{% elsif page.layout == 'archives'
50-
or page.layout == 'category'
51-
or page.layout == 'tag' %}
52-
{% assign type = "misc" %}
53-
{% else %}
54-
{% assign type = "commons" %}
55-
{% endif %}
45+
{% case page.layout %}
46+
{% when 'categories', 'post', 'page' %}
47+
{% assign type = page.layout %}
48+
{% when 'home', 'archives', 'category', 'tag' %}
49+
{% assign type = 'misc' %}
50+
{% else %}
51+
{% assign type = 'commons' %}
52+
{% endcase %}
5653

5754
{% capture script %}/assets/js/dist/{{ type }}.min.js{% endcapture %}
5855
<script defer src="{{ script | relative_url }}"></script>
5956

6057
{% if page.math %}
6158
<!-- MathJax -->
6259
<script>
63-
/* see: <https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options> */
64-
MathJax = {
65-
tex: {
66-
inlineMath: [ /* start/end delimiter pairs for in-line math */
67-
['$','$'],
68-
['\\(','\\)']
69-
],
70-
displayMath: [ /* start/end delimiter pairs for display math */
71-
['$$', '$$'],
72-
['\\[', '\\]']
73-
]
74-
}
75-
};
60+
/* see: <https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options> */
61+
MathJax = {
62+
tex: {
63+
/* start/end delimiter pairs for in-line math */
64+
inlineMath: [
65+
['$', '$'],
66+
['\\(', '\\)']
67+
],
68+
/* start/end delimiter pairs for display math */
69+
displayMath: [
70+
['$$', '$$'],
71+
['\\[', '\\]']
72+
]
73+
}
74+
};
7675
</script>
7776
<script src="{{ site.data.assets[origin].polyfill.js | relative_url }}"></script>
78-
<script id="MathJax-script" async src="{{ site.data.assets[origin].mathjax.js | relative_url }}">
79-
</script>
77+
<script id="MathJax-script" async src="{{ site.data.assets[origin].mathjax.js | relative_url }}"></script>
8078
{% endif %}
8179

8280
<!-- commons -->
@@ -95,5 +93,4 @@
9593
{% if site.google_analytics.id != empty and site.google_analytics.id %}
9694
{% include google-analytics.html %}
9795
{% endif %}
98-
9996
{% endif %}

0 commit comments

Comments
 (0)