probberechts / hexo-theme-cactus

:cactus: A responsive, clean and simple theme for Hexo.
https://probberechts.github.io/hexo-theme-cactus/
MIT License
3.15k stars 783 forks source link

Type Error: "config.language.substring is not a function" #271

Closed UM-Li closed 3 years ago

UM-Li commented 3 years ago

I tried setting multiple languages for the blog in the way recommended by official Hexo documentation.

In /_config.yml

language:
  - zh-CN
  - en
(...)
theme: cactus

When I run hexo generate, I get the following error:

ERROR { err:
   { TypeError: /home/pi/test/themes/cactus/layout/layout.ejs:2
       1| <!DOCTYPE html>
    >> 2| <html<%= config.language ? " lang=" + config.language.substring(0, 2) : ""%>>
       3| <%- partial('_partial/head') %>
       4| <body class="max-width mx-auto px3 <%- theme.direction -%>">
       5|     <% if (is_post()) { %>

   config.language.substring is not a function
       at eval (/home/pi/test/themes/cactus/layout/layout.ejs:12:71)
       at layout (/home/pi/test/node_modules/ejs/lib/ejs.js:682:17)
       at _View._compiled.locals [as _compiled] (/home/pi/test/node_modules/hexo/lib/theme/view.js:136:50)
       at _View.render (/home/pi/test/node_modules/hexo/lib/theme/view.js:39:17)
       at _compiled.then.result (/home/pi/test/node_modules/hexo/lib/theme/view.js:51:25)
       at tryCatcher (/home/pi/test/node_modules/bluebird/js/release/util.js:16:23)
       at Promise._settlePromiseFromHandler (/home/pi/test/node_modules/bluebird/js/release/promise.js:547:31)
       at Promise._settlePromise (/home/pi/test/node_modules/bluebird/js/release/promise.js:604:18)
       at Promise._settlePromise0 (/home/pi/test/node_modules/bluebird/js/release/promise.js:649:10)
       at Promise._settlePromises (/home/pi/test/node_modules/bluebird/js/release/promise.js:729:18)
       at _drainQueueStep (/home/pi/test/node_modules/bluebird/js/release/async.js:93:12)
       at _drainQueue (/home/pi/test/node_modules/bluebird/js/release/async.js:86:9)
       at Async._drainQueues (/home/pi/test/node_modules/bluebird/js/release/async.js:102:5)
       at Immediate.Async.drainQueues [as _onImmediate] (/home/pi/test/node_modules/bluebird/js/release/async.js:15:14)
       at runCallback (timers.js:705:18)
       at tryOnImmediate (timers.js:676:5)
       at processImmediate (timers.js:658:5) path: '/home/pi/test/themes/cactus/layout/layout.ejs' } } 'Render HTML failed: 2021/01/23/hello-world/index.html'

Package versions:

$ nodejs --version
v10.23.1

$ npm --version
5.8.0

$ hexo --version
INFO  Validating config
hexo: 5.3.0
hexo-cli: 4.2.0
os: Linux 5.4.83-v7l+ linux arm
http_parser: 2.9.4
node: 10.23.1
v8: 6.8.275.32-node.59
uv: 1.24.1
zlib: 1.2.11
brotli: 1.0.7
ares: 1.14.0
modules: 64
nghttp2: 1.41.0
napi: 7
openssl: 1.1.1d
icu: 63.1
unicode: 11.0
cldr: 34.0
tz: 2018e

Attached please see the full output of hexo generate: output.txt

UM-Li commented 3 years ago

! My mistake, Cactus does not support multi-language sites.

kamasylvia commented 1 year ago

I had the same problem. How did you solve it?