Skip to content

Commit 218b5f9

Browse files
authored
Merge branch 'master' into master
2 parents ff0cfca + a2fc8c0 commit 218b5f9

File tree

25 files changed

+275
-65
lines changed

25 files changed

+275
-65
lines changed

.github/ISSUE_TEMPLATE/other.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Please take extra precaution not to attach any secret environment variables (lik
2424
Please check followings before submitting a new issue.
2525

2626
- [ ] I have already confirmed other issue template and they are not different my want
27+
- [ ] Not a question, feature-request, bug
28+
- Please submit to [discussion](https://github.com/hexojs/hexo/discussions) if your issue is a question.
2729

2830
## Information
2931

.github/workflows/commenter.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ name: Commenter
22

33
on: [pull_request_target]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
commenter:
10+
permissions:
11+
pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
712
runs-on: ubuntu-latest
813
steps:
914
- name: Comment PR

.github/workflows/linter.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Linter
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
linter:
710
runs-on: ubuntu-latest

.github/workflows/release-drafter.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ on:
55
branches:
66
- master
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
update_release_draft:
13+
permissions:
14+
contents: write # for release-drafter/release-drafter to create a github release
15+
pull-requests: write # for release-drafter/release-drafter to add label to PR
1016
runs-on: ubuntu-latest
1117
steps:
1218
- uses: release-drafter/release-drafter@v5

.github/workflows/tester.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Tester
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
tester:
710
runs-on: ${{ matrix.os }}
@@ -23,6 +26,9 @@ jobs:
2326
env:
2427
CI: true
2528
coverage:
29+
permissions:
30+
checks: write # for coverallsapp/github-action to create new checks
31+
contents: read # for actions/checkout to fetch code
2632
runs-on: ${{ matrix.os }}
2733
strategy:
2834
matrix:

lib/extend/tag.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@ const getContext = (lines, errLine, location, type) => {
160160
* @return {Error} New error object with embedded context
161161
*/
162162
const formatNunjucksError = (err, input, source = '') => {
163+
err.message = err.message.replace('(unknown path)', source ? magenta(source) : '');
164+
163165
const match = err.message.match(/Line (\d+), Column \d+/);
164166
if (!match) return err;
165167
const errLine = parseInt(match[1], 10);
166168
if (isNaN(errLine)) return err;
167169

168170
// trim useless info from Nunjucks Error
169-
const splited = err.message.replace('(unknown path)', source ? magenta(source) : '').split('\n');
171+
const splited = err.message.split('\n');
170172

171173
const e = new Error();
172174
e.name = 'Nunjucks Error';
@@ -243,7 +245,9 @@ class Tag {
243245
options,
244246
cb
245247
);
246-
}).catch(err => Promise.reject(formatNunjucksError(err, str, source)))
248+
}).catch(err => {
249+
return Promise.reject(formatNunjucksError(err, str, source));
250+
})
247251
.asCallback(callback);
248252
}
249253
}

lib/hexo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Hexo extends EventEmitter {
151151
const dbPath = args.output || base;
152152

153153
if (/^(init|new|g|publish|s|deploy|render|migrate)/.test(this.env.cmd)) {
154-
this.log.d(`Writing database to ${dbPath}/db.json`);
154+
this.log.d(`Writing database to ${join(dbPath, 'db.json')}`);
155155
}
156156

157157
this.database = new Database({

lib/plugins/helper/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = ctx => {
3131
const is = require('./is');
3232
helper.register('is_current', is.current);
3333
helper.register('is_home', is.home);
34+
helper.register('is_home_first_page', is.home_first_page);
3435
helper.register('is_post', is.post);
3536
helper.register('is_page', is.page);
3637
helper.register('is_archive', is.archive);

lib/plugins/helper/is.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function isHomeHelper() {
2323
return Boolean(this.page.__index);
2424
}
2525

26+
function isHomeFirstPageHelper() {
27+
return Boolean(this.page.__index) && this.page.current === 1;
28+
}
29+
2630
function isPostHelper() {
2731
return Boolean(this.page.__post);
2832
}
@@ -79,6 +83,7 @@ function isTagHelper(tag) {
7983

8084
exports.current = isCurrentHelper;
8185
exports.home = isHomeHelper;
86+
exports.home_first_page = isHomeFirstPageHelper;
8287
exports.post = isPostHelper;
8388
exports.page = isPageHelper;
8489
exports.archive = isArchiveHelper;

lib/plugins/helper/mail_to.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const { htmlTag } = require('hexo-util');
4-
const qs = require('querystring');
54
const { default: moize } = require('moize');
65

76
function mailToHelper(path, text, options = {}) {
@@ -28,7 +27,7 @@ function mailToHelper(path, text, options = {}) {
2827
}
2928
});
3029

31-
const querystring = qs.stringify(data);
30+
const querystring = new URLSearchParams(data).toString();
3231
if (querystring) attrs.href += `?${querystring}`;
3332

3433
return htmlTag('a', attrs, text);

0 commit comments

Comments
 (0)