theme-next / hexo-theme-next

Elegant and powerful theme for Hexo.
https://theme-next.org
Other
8.15k stars 2.05k forks source link

hexo generate: TypeError: Cannot read property 'length' of null #654

Closed MoeexT closed 5 years ago

MoeexT commented 5 years ago

I agree and want to create new issue


Expected behavior

Successfully executed the command before. 之前都顺利构建成功的。

Actual behavior

I have not changed the files that have appeared in the debug information below. 下面debug信息中出现过的文件我都没有更改过。

16:26:10.947 DEBUG Processed: source/lib/three/three.min.js
16:26:11.477 FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Template render error: (unknown path)
  TypeError: Cannot read property 'length' of null
    at Object._prettifyError (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\nunjucks\src\lib.js:36:11)
    at C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\nunjucks\src\environment.js:551:19
    at Template.root [as rootRenderFunc] (eval at _compile (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\nunjucks\src\environment.js:621:18), <anonymous>:117:3)
    at Template.render (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\nunjucks\src\environment.js:540:10)
    at Environment.renderString (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\nunjucks\src\environment.js:364:17)
    at Promise.fromCallback.cb (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\hexo\lib\extend\tag.js:62:48)
    at tryCatcher (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\util.js:16:23)
    at Function.Promise.fromNode.Promise.fromCallback (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\promise.js:180:30)
    at Tag.render (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\hexo\lib\extend\tag.js:62:18)
    at Object.onRenderEnd (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\hexo\lib\hexo\post.js:282:20)
    at Promise.then.then.result (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\hexo\lib\hexo\render.js:65:19)
    at tryCatcher (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\promise.js:694:18)
    at _drainQueueStep (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\async.js:138:12)
    at _drainQueue (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\async.js:131:9)
    at Async._drainQueues (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\async.js:147:5)
    at Immediate.Async.drainQueues (C:\Users\Administrator\OneDrive - business\文档\GitHub\Hexo\yuwancumian666.github.io\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
16:26:11.538 DEBUG Database saved

Steps to reproduce the behavior

  1. cloned repositories In order for the settings(theme/_config.yml) to take effect, I cloned several repositories from GitHub and renamed the folder. 为了使设置(theme/_config.yml)生效,我从GitHub上克隆了几个仓库并重命名了文件夹。

  2. Changed file(s) Sources of the first and second items:https://github.com/iissnan/hexo-theme-next/issues/1043 以下两点的来源:https://github.com/iissnan/hexo-theme-next/issues/1043

    • Hexo\yuwancumian666.github.io\themes\next\source\css\_common\components\tags\group-pictures.styl In order to solve the problem of not being able to side by side pictures while using "{% gp 1-2 %} img1 img2 {% endgp %}" 更改这个文件是为了解决当使用"{% gp 1-2 %} img1 img2 {% endgp %}"仍不能并排图片的问题
      .page-post-detail .post-body .group-picture-column {
      // float: none;
      margin-top: 10px;
      // width: auto !important;
      img { margin: 0 auto; }
      }
    • Hexo\yuwancumian666.github.io\themes\next\source\js\src\utils.js In order to solve the problem of side-by-side pictures, the preview cannot be enlarged. 注释此行是为了解决并排图片不能放大预览的问题。
      wrapImageWithFancyBox: function() {
      $('.content img')
      .not(':hidden')
      // .not('.group-picture img, .post-gallery img')
      .each(function() {
  3. N/A

I just migrated the blog from Jekyll to hexo, so the engine used by the site is still Jekyll. 我刚刚把博客从Jekyll迁移到hexo,所以网站用的引擎还是Jekyll。

Node.js and NPM Information

node -v
v10.15.2
npm -v
6.4.1

Package dependencies Information

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.8.0"
  },
  "dependencies": {
    "hexo": "^3.8.0",
    "hexo-generator-archive": "^0.1.5",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-index": "^0.2.1",
    "hexo-generator-searchdb": "^1.0.8",
    "hexo-generator-tag": "^0.2.0",
    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-marked": "^0.3.2",
    "hexo-renderer-stylus": "^0.3.3",
    "hexo-server": "^0.3.3"
  }
}

Hexo Information

Hexo version

hexo: 3.8.0
hexo-cli: 1.1.0
os: Windows_NT 10.0.17763 win32 x64
http_parser: 2.8.0
node: 10.15.2
v8: 6.8.275.32-node.12
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

Hexo Configuration

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Hammer's Blog
subtitle: 哝,你的鱼丸~
description: 
keywords: 
author: 鱼丸粗面666
language: zh-CN
timezone: UTC

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://yuwancumian666.github.io/
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :year-:month-:day-:title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: 4

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next  # landscape

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type:

NexT Information

NexT Version:

NexT Scheme:

NexT Configuration:

footer:
  since: 2017

menu:
  home: / || home
  tags: /tags/ || tags
  categories: /categories/ || th
  archives: /archives/ || archive
  about: /about/ || user

social:
  GitHub: https://github.com/yuwancumian666 || github
  E-Mail: mailto:yuwancumian666@gmail.com || envelope
  微博: http://weibo.com/starmon || weibo
  微信: /images/wechat.jpg || weixin
  StackOverflow: https://stackoverflow.com/users/9013632/yuwancumian666 || stack-overflow
  知乎: http://www.zhihu.com/people/yu-wan-cu-mian-666 || graduation-cap

github_banner: https://github.com/yuwancumian666 || Follow me on GitHub

links_icon: link
links_title: 友情链接
# links_layout: block
links_layout: inline
links:
  #Title: http://example.com
  Rat's Blog: https://www.moerats.com/
  秋水逸冰: https://teddysun.com/
  就是爱生活: https://www.94ish.me/
  Hexo-NexT: http://theme-next.iissnan.com/
  Jekyll-NexT: http://theme-next.simpleyyt.com/
  FontAwesome: http://www.fontawesome.com.cn/faicons/
  Jemoji: https://www.webpagefx.com/tools/emoji-cheat-sheet/

avatar:
  url: /images/luna.png #/images/avatar.gif

sidebar:
  position: right

# Code Highlight theme
highlight_theme: night bright

font:
  enable: true

math:
  enable: true

disqus:
  enable: true
  shortname: yuwancumian666
  count: true
  lazyload: true

# `npm install hexo-generator-searchdb --save`
local_search: 
  enable: true

# `git clone https://github.com/theme-next/theme-next-fancybox3`
# then renamed  "theme-next-fancybox3" -> "fancybox"
fancybox: true

pace: true

canvas_ribbon:
  enable: true

fontawesome: https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css

Other Information

Google Chrome: 版本 72.0.3626.119(正式版本) (64 位) Microsoft Windows, 版本 1809 (OS 内部版本 17763.316), Win10家庭版

MoeexT commented 5 years ago

已找到问题所在: markdown文件中,本来要使用反引号引用行内代码{% gp 1-n %} ![]() ![]() {% endgp %},但是这样会被hexo解释,而不是原文插入到html里,而且一开始的写法是:{% gp 1-n %} {% endgp %},导致图片个数为空,所以才报TypeError: Cannot read property 'length' of null 尝试用\{\% gp 1-n \%\} ![]() ![]() \{\% endgp \%\}写,不会被hexo解释,但是在页面上会出现\,导致文章不是很美观。所以,那位大佬知道“在行内代码块插入标签插件而不被解释”的较完美的解决办法?

sli1989 commented 5 years ago

use

{% codeblock [title] [lang:language] [url] [link text] %}
code snippet
{% endcodeblock %}
MoeexT commented 5 years ago

@sli1989 写在{% codeblock %} {% endcodeblock %}中的标签插件仍然会被解释,不过这样变成了代码块中的html。

stevenjoezhang commented 5 years ago

Try this:

```md
{% gp 1-n %} {% endgp %}
```

tags in inline <code> will be interpreted, it might be a bug of Hexo. See also: https://hexo.io/zh-cn/docs/tag-plugins.html