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

如果文章的tag以数字3开头运行hexo s就会报错 #3840

Open
note4 opened this issue Nov 6, 2019 · 9 comments
Open

如果文章的tag以数字3开头运行hexo s就会报错 #3840

note4 opened this issue Nov 6, 2019 · 9 comments

Comments

@note4
Copy link

@note4 note4 commented Nov 6, 2019

##标签示范
tags: [315消费者维权日]

tags: [金山软件,金山毒霸,315消费者维权日]

报错提示

ERROR Process failed: _posts/177.md
TypeError: str must be a string!
at slugize (/Users/cccc/git/hexo-blog/node_modules/hexo-util/lib/slugize.js:9:38)
at Model._Document.Document. (/Users/cccc/git/hexo-blog/node_modules/hexo/lib/models/tag.js:22:12)
at Model._Document.Document.slug (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/types/virtual.js:70:22)
at Model._Document.Document.Document.toObject (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/document.js:79:42)
at Database._Model.Model.Model._insertOne (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/model.js:189:21)
at /Users/cccc/git/hexo-blog/node_modules/warehouse/lib/model.js:214:17
at tryCatcher (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/util.js:16:23)
at /Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/using.js:185:26
at tryCatcher (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/c'c'c'c/git/hexo-yijile/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:694:18)
at Promise._fulfill (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:694:18)
at _drainQueueStep (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:147:5)

@YoshinoriN YoshinoriN added the question label Nov 7, 2019
@YoshinoriN

This comment has been minimized.

Copy link
Member

@YoshinoriN YoshinoriN commented Nov 7, 2019

Can not reproduce this phenomenon in Hexo 4. Please write more details.

@SukkaW

This comment has been minimized.

Copy link
Member

@SukkaW SukkaW commented Nov 10, 2019

@note4 What about other numbers? Or just number 3?

---
tags:
  - 315
  - 2_Test
---
@note4

This comment has been minimized.

Copy link
Author

@note4 note4 commented Nov 15, 2019

Can not reproduce this phenomenon in Hexo 4. Please write more details.

hexo: 3.8.0
hexo-cli: 1.1.0
os: Darwin 19.0.0 darwin x64
http_parser: 2.8.0
node: 10.15.3
v8: 6.8.275.32-node.51
uv: 1.23.2
zlib: 1.2.11
ares: 1.15.0
modules: 64
nghttp2: 1.34.0
napi: 3
openssl: 1.1.0j
icu: 62.1
unicode: 11.0
cldr: 33.1
tz: 2018e

ERROR Process failed: _posts/177.md
TypeError: str must be a string!
at slugize (/Users/cccc/git/hexo-blog/node_modules/hexo-util/lib/slugize.js:9:38)
at Model._Document.Document. (/Users/cccc/git/hexo-blog/node_modules/hexo/lib/models/tag.js:22:12)
at Model._Document.Document.slug (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/types/virtual.js:70:22)
at Model._Document.Document.Document.toObject (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/document.js:79:42)
at Database._Model.Model.Model._insertOne (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/model.js:189:21)
at /Users/cccc/git/hexo-blog/node_modules/warehouse/lib/model.js:214:17
at tryCatcher (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/util.js:16:23)
at /Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/using.js:185:26
at tryCatcher (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:694:18)
at Promise._fulfill (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:694:18)
at _drainQueueStep (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:147:5)
ERROR Process failed: _posts/215.md
TypeError: str must be a string!
at slugize (/Users/cccc/git/hexo-blog/node_modules/hexo-util/lib/slugize.js:9:38)
at Model._Document.Document. (/Users/cccc/git/hexo-blog/node_modules/hexo/lib/models/tag.js:22:12)
at Model._Document.Document.slug (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/types/virtual.js:70:22)
at Model._Document.Document.Document.toObject (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/document.js:79:42)
at Database._Model.Model.Model._insertOne (/Users/cccc/git/hexo-blog/node_modules/warehouse/lib/model.js:189:21)
at /Users/cccc/git/hexo-blog/node_modules/warehouse/lib/model.js:214:17
at tryCatcher (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/util.js:16:23)
at /Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/using.js:185:26
at tryCatcher (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:694:18)
at Promise._fulfill (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/promise.js:694:18)
at _drainQueueStep (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/cccc/git/hexo-blog/node_modules/bluebird/js/release/async.js:147:5)
这是全部报错信息了

@note4

This comment has been minimized.

Copy link
Author

@note4 note4 commented Nov 15, 2019

tags:
  - 315
  - 2_Test

太诡异了,似乎是 315消费者维权日 这个TAG 触发的,315改成312都没问题,或者后面任意改一个字也都OK

@note4

This comment has been minimized.

Copy link
Author

@note4 note4 commented Nov 15, 2019

Can not reproduce this phenomenon in Hexo 4. Please write more details.

难道hexo有词汇黑名单?其中就包含315消费者维权日

@SukkaW

This comment has been minimized.

Copy link
Member

@SukkaW SukkaW commented Nov 15, 2019

@note4 Of course Hexo has no blacklisted words. You can review the Hexo's source code if you do not believe.

I wonder the number mixed with character might cause TypeError when Hexo read YAML. The safest way is to wrap your keywords into strings, for example "315消费".

@snowyu

This comment has been minimized.

Copy link

@snowyu snowyu commented Nov 23, 2019

yaml treat 315 as number, so the tag should

tag
  - '315'
@note4

This comment has been minimized.

Copy link
Author

@note4 note4 commented Dec 2, 2019

黑名单只是玩笑话,很好奇这个bug的原理,今天发现又好了,谢谢各位大佬了。

弱弱的问一句,如果文件后缀为'.MD'就不会生成内容?

@curbengh curbengh removed the question label Dec 9, 2019
@curbengh

This comment has been minimized.

Copy link
Contributor

@curbengh curbengh commented Dec 9, 2019

如果文件后缀为'.MD'就不会生成内容

yes, it must be in lowercase .md. To avoid file creation issue, I recommend to always use lowercase in folder/filename especially in case-insensitive file system used in Windows & Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.