Skip to content

Commit a928d9a

Browse files
authored
Merge pull request #370 from EvanNotFound/dev
v2.6.2
2 parents ac35a18 + d69e8b5 commit a928d9a

File tree

13 files changed

+163
-76
lines changed

13 files changed

+163
-76
lines changed

.github/workflows/preview.yml

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,73 @@ on:
1414
jobs:
1515
Deploy-Preview:
1616
runs-on: ubuntu-latest
17-
17+
# if: >
18+
# github.event_name == 'workflow_dispatch' ||
19+
# (github.event_name == 'push' && github.repository == 'EvanNotFound/hexo-theme-redefine') ||
20+
# (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'EvanNotFound/hexo-theme-redefine')
1821
steps:
1922
- id: script
20-
uses: actions/github-script@v3
23+
uses: actions/github-script@v6
2124
with:
2225
script: |
2326
const isPr = [ 'pull_request', 'pull_request_target' ].includes(context.eventName)
2427
core.setOutput('ref', isPr ? context.payload.pull_request.head.ref : context.ref)
2528
core.setOutput('repo', isPr ? context.payload.pull_request.head.repo.full_name : context.repo.full_name)
26-
2729
2830
- name: Checkout theme repository
29-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
3032
with:
3133
path: 'theme' # Checkout the theme repository into a directory named 'theme'
3234
ref: ${{ steps.script.outputs.ref }}
3335
repository: ${{ steps.script.outputs.repo }}
3436

3537
- name: Setup Node.js
36-
uses: actions/setup-node@v2
38+
uses: actions/setup-node@v3
3739
with:
3840
node-version: '20.x' # Specify your required Node.js version
3941

4042
- name: Clone Hexo site repository
4143
run: git clone https://github.com/EvanNotFound/redefine-demo.git hexo-site
4244

45+
- name: Set up Python
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: '3.x' # Ensure compatibility with Python 3.x
49+
50+
- name: Install PyYAML
51+
run: pip install pyyaml
52+
53+
- name: Enable Developer Mode in Config
54+
run: |
55+
echo "import yaml
56+
import logging
57+
58+
# Set up logging
59+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
60+
61+
try:
62+
# Load YAML file
63+
with open('hexo-site/_config.redefine.yml', 'r') as file:
64+
config = yaml.safe_load(file)
65+
logging.info('YAML file loaded successfully.')
66+
67+
# Modify the developer mode and CDN settings
68+
config['developer']['enable'] = True
69+
logging.info('Developer mode set to True.')
70+
71+
config['cdn']['enable'] = False
72+
logging.info('CDN set to False.')
73+
74+
# Save the modified YAML file
75+
with open('hexo-site/_config.redefine.yml', 'w') as file:
76+
yaml.safe_dump(config, file, default_flow_style=False, sort_keys=False)
77+
logging.info('YAML file saved with new settings.')
78+
79+
except Exception as e:
80+
logging.error('An error occurred: {}'.format(e))
81+
" > update_yaml.py
82+
python update_yaml.py
83+
4384
- name: Move theme into Hexo site
4485
run: |
4586
mv theme hexo-site/themes/redefine
@@ -56,23 +97,11 @@ jobs:
5697
npm uninstall hexo-theme-redefine
5798
npm run build
5899
59-
60-
- name: Install Vercel CLI
61-
run: npm install --global vercel@canary
62-
63100
- name: Change directory to hexo-site
64101
run: echo "HEXO_SITE_DIR=${{ github.workspace }}/hexo-site" >> $GITHUB_ENV
65102

66-
# - uses: amondnet/vercel-action@v20 #deploy
67-
# with:
68-
# vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
69-
# vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required
70-
# github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
71-
# vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}} #Required
72-
# working-directory: ${{ env.HEXO_SITE_DIR }}
73-
74103
- name: Deploy to Vercel Action
75-
uses: EvanNotFound/vercel-deployment-for-github-actions@v1
104+
uses: EvanNotFound/vercel-deployment-for-github-actions@v1.1.0
76105
with:
77106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78107
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

.github/workflows/production-demo.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
steps:
1616
- name: Checkout theme repository
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818
with:
1919
path: 'theme' # Checkout the theme repository into a directory named 'theme'
2020

@@ -43,8 +43,8 @@ jobs:
4343
npm run build
4444
4545
46-
- name: Install Vercel CLI
47-
run: npm install --global vercel@canary
46+
# - name: Install Vercel CLI
47+
# run: npm install --global vercel@canary
4848

4949
- name: Change directory to hexo-site
5050
run: echo "HEXO_SITE_DIR=${{ github.workspace }}/hexo-site" >> $GITHUB_ENV
@@ -58,7 +58,7 @@ jobs:
5858
# working-directory: ${{ env.HEXO_SITE_DIR }}
5959

6060
- name: Deploy to Vercel Action
61-
uses: EvanNotFound/vercel-deployment-for-github-actions@v1
61+
uses: EvanNotFound/vercel-deployment-for-github-actions@v1.1.0
6262
with:
6363
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6464
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ To update hexo-theme-redefine, you can run the same **npm** command
100100
$ npm install hexo-theme-redefine@latest
101101
```
102102

103-
Another method is by **git clone**
103+
If you installed the theme by **git clone**, you can update the theme by running the following command
104104

105105
```sh
106-
$ git clone https://github.com/EvanNotFound/hexo-theme-redefine.git themes/redefine
106+
$ cd themes/redefine
107+
$ git pull
107108
```
108109

109110

README_zh-CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ $ npm install hexo-theme-redefine@latest
104104
通过 `git` 更新到最新的 `main` 分支:
105105

106106
```sh
107-
$ git clone https://github.com/EvanNotFound/hexo-theme-redefine.git themes/redefine
107+
$ cd themes/redefine
108+
$ git pull
108109
```
109110

110111

README_zh-TW.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ $ npm install hexo-theme-redefine@latest
105105
通過 `git` 更新到最新的 `main` 分支:
106106

107107
```sh
108-
$ git clone https://github.com/EvanNotFound/hexo-theme-redefine.git themes/redefine
108+
$ cd themes/redefine
109+
$ git pull
109110
```
110111

111112

_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,10 @@ cdn:
445445
# Whether to enable CDN
446446
enable: false
447447
# CDN Provider
448-
provider: staticfile # staticfile, bootcdn, cdnjs, jsdelivr, unpkg, custom
448+
provider: zstatic # zstatic, sustech, staticfile, bootcdn, cdnjs, jsdelivr, unpkg, aliyun, custom
449449
# Custom CDN URL
450450
# format example: https://cdn.custom.com/hexo-theme-redefine/${version}/source/${path}
451-
# The ${path} must be in the source folder of the theme
451+
# The ${path} must leads to the root of the "source" folder of the theme
452452
custom_url:
453453
# CDN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end
454454

layout/_widgets/archive-list.ejs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
<% const postList = createNewArchivePosts(posts_new) %>
2-
<% let cachedDate = null %>
32
<div class="archive-list-container">
43
<% postList.forEach(postYear => { %>
54
<section class="archive-item mb-spacing-unit last:mb-0">
65
<div class="archive-item-header flex flex-row items-center mb-2">
76
<span class="archive-year font-semibold text-3xl mr-2"><%= postYear.year %></span>
87
<span class="archive-year-post-count text-xs md:text-sm font-bold rounded-small bg-third-background-color py-[2px] px-[10px] border border-border-color"><%= postYear.postList.length %></span>
98
</div>
9+
<% let previousDate = null; %>
1010
<ul class="article-list pl-0 md:pl-8 text-lg leading-[1.5]">
11-
<% postYear.postList.forEach(post => { %>
12-
<% if (!cachedDate || cachedDate != date(post.date, 'MM-DD')) { %>
13-
<% cachedDate = date(post.date, 'MM-DD') %>
14-
<li class="article-item space-y-2 px-6 pt-10 pb-2 text-xl relative border-l-2 border-border-color" date-is='<%= date(post.date, 'MM-DD') %>'>
15-
<% } %>
16-
<% if (cachedDate == date(post.date, 'MM-DD')) { %>
17-
<a href="<%- url_for(post.path) %>" class="block overflow-hidden w-fit">
18-
<span class="article-title mb-0.5 text-2xl"><%= post.title %></span>
19-
</a>
20-
<% } else {%>
21-
<% cachedDate = date(post.date, 'MM-DD') %>
22-
<a href="<%- url_for(post.path) %>" class="block overflow-hidden w-fit">
23-
<span class="article-title mb-0.5 text-2xl"><%= post.title %></span>
24-
</a>
25-
</li>
26-
<% } %>
27-
<% }) %>
11+
<% postYear.postList.forEach(post => { %>
12+
<% const currentDate = date(post.date, 'MM-DD'); %>
13+
<% if (previousDate !== currentDate) { %>
14+
<% if (previousDate) { %>
15+
</li>
16+
<% } %> <!-- Close the previous LI if not the first item -->
17+
<li class="article-item space-y-2 px-6 pt-10 pb-2 text-xl relative border-l-2 border-border-color" date-is='<%= currentDate %>'>
18+
<% } %>
19+
<a href="<%- url_for(post.path) %>" class="block overflow-hidden w-fit">
20+
<span class="article-title my-0.5 text-2xl"><%= post.title %></span>
21+
</a>
22+
<% previousDate = currentDate; %>
23+
<% }) %>
24+
</li> <!-- Ensure the last item is properly closed -->
2825
</ul>
2926
</section>
3027
<% }) %>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hexo-theme-redefine",
3-
"version": "2.6.1",
3+
"version": "2.6.2",
44
"private": false,
55
"description": "Redefine your writing with Hexo Theme Redefine.",
66
"scripts": {

scripts/helpers/themeHelpers.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ hexo.extend.helper.register("renderJS", function (path) {
9393
const cdnProviders = {
9494
staticfile: "https://cdn.staticfile.net",
9595
bootcdn: "https://cdn.bootcdn.net/ajax/libs",
96+
sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs",
97+
zstatic: "https://s4.zstatic.net/ajax/libs",
9698
cdnjs: "https://cdnjs.cloudflare.com/ajax/libs",
9799
unpkg: "https://unpkg.com",
98100
jsdelivr: "https://cdn.jsdelivr.net/npm",
@@ -120,7 +122,9 @@ hexo.extend.helper.register("renderJS", function (path) {
120122
} else if (
121123
this.theme.cdn.provider === "staticfile" ||
122124
this.theme.cdn.provider === "bootcdn" ||
123-
this.theme.cdn.provider === "cdnjs"
125+
this.theme.cdn.provider === "cdnjs" ||
126+
this.theme.cdn.provider === "sustech" ||
127+
this.theme.cdn.provider === "zstatic"
124128
) {
125129
return this.theme.cdn.enable
126130
? `<script src="${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}"></script>`
@@ -150,6 +154,8 @@ hexo.extend.helper.register("renderJSModule", function (path) {
150154
const cdnProviders = {
151155
staticfile: "https://cdn.staticfile.net",
152156
bootcdn: "https://cdn.bootcdn.net/ajax/libs",
157+
sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs",
158+
zstatic: "https://s4.zstatic.net/ajax/libs",
153159
cdnjs: "https://cdnjs.cloudflare.com/ajax/libs",
154160
unpkg: "https://unpkg.com",
155161
jsdelivr: "https://cdn.jsdelivr.net/npm",
@@ -177,7 +183,9 @@ hexo.extend.helper.register("renderJSModule", function (path) {
177183
} else if (
178184
this.theme.cdn.provider === "staticfile" ||
179185
this.theme.cdn.provider === "bootcdn" ||
180-
this.theme.cdn.provider === "cdnjs"
186+
this.theme.cdn.provider === "cdnjs" ||
187+
this.theme.cdn.provider === "sustech" ||
188+
this.theme.cdn.provider === "zstatic"
181189
) {
182190
return this.theme.cdn.enable
183191
? `<script type="module" src="${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}"></script>`
@@ -207,6 +215,8 @@ hexo.extend.helper.register("renderJSPath", function (path) {
207215
const cdnProviders = {
208216
staticfile: "https://cdn.staticfile.net",
209217
bootcdn: "https://cdn.bootcdn.net/ajax/libs",
218+
sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs",
219+
zstatic: "https:https://s4.zstatic.net/ajax/libs",
210220
cdnjs: "https://cdnjs.cloudflare.com/ajax/libs",
211221
unpkg: "https://unpkg.com",
212222
jsdelivr: "https://cdn.jsdelivr.net/npm",
@@ -232,7 +242,9 @@ hexo.extend.helper.register("renderJSPath", function (path) {
232242
} else if (
233243
this.theme.cdn.provider === "staticfile" ||
234244
this.theme.cdn.provider === "bootcdn" ||
235-
this.theme.cdn.provider === "cdnjs"
245+
this.theme.cdn.provider === "cdnjs" ||
246+
this.theme.cdn.provider === "sustech" ||
247+
this.theme.cdn.provider === "zstatic"
236248
) {
237249
return this.theme.cdn.enable
238250
? `${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}`
@@ -260,12 +272,14 @@ hexo.extend.helper.register("renderJSPath", function (path) {
260272
hexo.extend.helper.register("renderCSS", function (path) {
261273
const _css = hexo.extend.helper.get("css").bind(hexo);
262274
const cdnProviders = {
263-
staticfile: "//cdn.staticfile.net",
264-
bootcdn: "//cdn.bootcdn.net/ajax/libs",
265-
cdnjs: "//cdnjs.cloudflare.com/ajax/libs",
266-
unpkg: "//unpkg.com",
267-
jsdelivr: "//cdn.jsdelivr.net/npm",
268-
aliyun: "//evan.beee.top/projects",
275+
staticfile: "https://cdn.staticfile.net",
276+
bootcdn: "https://cdn.bootcdn.net/ajax/libs",
277+
sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs",
278+
zstatic: "https://s4.zstatic.net/ajax/libs",
279+
cdnjs: "https://cdnjs.cloudflare.com/ajax/libs",
280+
unpkg: "https://unpkg.com",
281+
jsdelivr: "https://cdn.jsdelivr.net/npm",
282+
aliyun: "https://evan.beee.top/projects",
269283
custom: this.theme.cdn.custom_url,
270284
};
271285

@@ -289,7 +303,9 @@ hexo.extend.helper.register("renderCSS", function (path) {
289303
} else if (
290304
this.theme.cdn.provider === "staticfile" ||
291305
this.theme.cdn.provider === "bootcdn" ||
292-
this.theme.cdn.provider === "cdnjs"
306+
this.theme.cdn.provider === "cdnjs" ||
307+
this.theme.cdn.provider === "sustech" ||
308+
this.theme.cdn.provider === "zstatic"
293309
) {
294310
return this.theme.cdn.enable
295311
? `<link rel="stylesheet" href="${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}">`

scripts/modules/btn.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
'use strict';
1+
"use strict";
22

33
function postBtn(args) {
4-
if(/::/g.test(args)){
5-
args = args.join(' ').split('::');
4+
if (/::/g.test(args)) {
5+
args = args.join(" ").split("::");
6+
} else {
7+
args = args.join(" ").split(",");
68
}
7-
else{
8-
args = args.join(' ').split(',');
9-
}
10-
let cls = '';
11-
let text = '';
12-
let url = '';
13-
let icon = '';
9+
let cls = "";
10+
let text = "";
11+
let url = "";
12+
let icon = "";
1413
if (args.length > 3) {
1514
cls = args[0];
1615
text = args[1];
1716
url = args[2];
1817
icon = args[3];
1918
} else if (args.length > 2) {
20-
if (args[2].indexOf(' fa-') > -1) {
19+
if (args[2].indexOf(" fa-") > -1) {
2120
// text, url, icon
2221
text = args[0];
2322
url = args[1];
@@ -39,17 +38,16 @@ function postBtn(args) {
3938
text = text.trim();
4039
url = url.trim();
4140
if (url.length > 0) {
42-
url = 'href=\'' + url + '\'';
41+
url = "href='" + url + "'";
4342
}
4443
if (cls.length > 0) {
45-
cls = ' ' + cls;
44+
cls = " " + cls;
4645
}
4746
if (icon.length > 0) {
4847
return `<a class="button ${cls}" ${url} title='${text}'><i class='${icon}'></i> ${text}</a>`;
4948
}
5049
return `<a class="button ${cls}" ${url} title='${text}'>${text}</a>`;
51-
5250
}
5351

54-
hexo.extend.tag.register('btn', postBtn);
55-
hexo.extend.tag.register('button', postBtn);
52+
hexo.extend.tag.register("btn", postBtn);
53+
hexo.extend.tag.register("button", postBtn);

0 commit comments

Comments
 (0)