Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

external_links.js file needs to be improved #4122

Open
ProfessorX opened this issue Feb 10, 2020 · 2 comments
Open

external_links.js file needs to be improved #4122

ProfessorX opened this issue Feb 10, 2020 · 2 comments

Comments

@ProfessorX
Copy link

@ProfessorX ProfessorX commented Feb 10, 2020

Check List

Please check followings before submitting a new feature request.

  • [x ] I have already read Docs page
  • [ x] I have already searched existing issues

Feature Request

Others

Details of the issue and bug please refer to the issue that I posted on theme-next repo.

Portal here: theme-next/hexo-theme-next#1370

OK for clarity I will use Chinese hereafter.

在Post md文件的标题中,如果用了 “%” 英文的百分比符号,会导致在hexo g的时候报错。

如:

---
layout: post
title:  "如果经济危机全面爆发,货币贬值99.9999% 那么我欠银行的100万房贷是还100万,还是100亿?"
date:   2019-11-24  19:00:00 +0800
categories: Report
tags: [World, Economy, Bank, Loan, Depreciation]
---

一个post抬头如上所示,保存后用hexo g进行编译,环境:

+-- hexo@4.2.0
+-- hexo-generator-archive@0.1.5
+-- hexo-generator-category@0.1.3
+-- hexo-generator-index@0.2.1
+-- hexo-generator-search@2.4.0
+-- hexo-generator-tag@0.2.0
+-- hexo-renderer-ejs@0.3.1
+-- hexo-renderer-marked@1.0.1
+-- hexo-renderer-stylus@0.3.3
`-- hexo-server@0.3.3

然后会报如下所示的错误:

TypeError: Cannot read property 'replace' of null
    at Hexo.externalLinkFilter (C:\Users\abrah\Documents\blog\node_modules\hexo\lib\plugins\filter\after_render\external_link.js:22:15)
    at Hexo.tryCatcher (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Hexo.<anonymous> (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\method.js:15:34)
    at C:\Users\abrah\Documents\blog\node_modules\hexo\lib\extend\filter.js:62:52
    at tryCatcher (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Object.gotValue (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\reduce.js:155:18)
    at Object.gotAccum (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\reduce.js:144:25)
    at Object.tryCatcher (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\promise.js:517:31)          at Promise._settlePromise (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\promise.js:574:18)
    at Promise._settlePromiseCtx (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\promise.js:611:10)
    at _drainQueueStep (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\async.js:142:12)
    at _drainQueue (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\async.js:131:9)
    at Async._drainQueues (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\abrah\Documents\blog\node_modules\bluebird\js\release\async.js:17:14)
    at processImmediate (internal/timers.js:439:21)

将百分比符号去掉或者修改为中文“百分比”即可正常编译。因为我不懂js,所以没办法手工修改加 pull request.

以上,此致敬礼。

@ProfessorX

This comment has been minimized.

Copy link
Author

@ProfessorX ProfessorX commented Feb 10, 2020

Update:
This works OK with hexo 4.0.0 and theme-next 7.5.0 or below.

@ProfessorX

This comment has been minimized.

Copy link
Author

@ProfessorX ProfessorX commented Feb 10, 2020

灵夫:
感觉上是

灵夫:
你对一个null变量调用了replace方法

灵夫:
要不提前判断下,传入字符串变量问题


@SukkaW
Please help refactor this js file, again. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.