amehime / hexo-renderer-multi-markdown-it

A renderer plugin for Hexo based on Markdown-it and auto Minify HTML, CSS, JS.
http://amehime.github.io/shoka
MIT License
36 stars 10 forks source link

The "id" argument must be of type string. Received an instance of Object #5

Open panxw opened 1 year ago

panxw commented 1 year ago

follewed by the article steps: https://sang.pub/posts/48158/

when I executedhexo server, got:

TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received an instance of Object
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at Module.require (node:internal/modules/cjs/loader:992:3)
    at require (node:internal/modules/cjs/helpers:102:18)
    at D:\hexotest\test\node_modules\hexo-renderer-markdown-it\lib\renderer.js:55:27
    at Array.reduce (<anonymous>)
    at new Renderer (D:\hexotest\test\node_modules\hexo-renderer-markdown-it\lib\renderer.js:39:29)
    at D:\hexotest\test\node_modules\hexo-renderer-markdown-it\index.js:32:18
    at D:\hexotest\test\node_modules\hexo\lib\hexo\index.js:305:14
    at tryCatcher (D:\hexotest\test\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (D:\hexotest\test\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (D:\hexotest\test\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (D:\hexotest\test\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (D:\hexotest\test\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (node:internal/timers:464:21)

then I setted console.log(plugins) for plugins in hexo-renderer-markdown-it\lib\renderer.js, got:

[
  {
    plugin: {
      name: 'markdown-it-toc-and-anchor',
      enable: true,
      options: [Object]
    }
  },
  {
    plugin: {
      name: 'markdown-it-multimd-table',
      enable: true,
      options: [Object]
    }
  },
  {
    plugin: { name: './markdown-it-furigana', enable: true, options: [Object] }
  },
  {
    plugin: { name: './markdown-it-spoiler', enable: true, options: [Object] }
  }
]

the yml plugins config was not compatiable with render.js, then I changed plugins in yml to:

  plugins: # markdown-it 插件设置
    - name: markdown-it-multimd-table
      enable: true
      options:
        multiline: true
        rowspan: true
        headerless: true
    - name: markdown-it-toc-and-anchor
      enable: true
      options:
        tocClassName: 'toc'
        anchorClassName: 'anchor'
    - name: ./markdown-it-furigana
      enable: true
      options:
        fallbackParens: "()"
    - name: ./markdown-it-spoiler
      enable: true
      options:
        title: "你知道得太多了"

when executed, 'markdown-it-toc-and-anchor', 'markdown-it-furigana', 'markdown-it-spoiler' , outputs:

ERROR Plugin load failed: hexo-renderer-markdown-it
TypeError: plugin.apply is not a function
    at MarkdownIt.use (D:\hexotest\test\node_modules\markdown-it\lib\index.js:497:10)
    at D:\hexotest\test\node_modules\hexo-renderer-markdown-it\lib\renderer.js:53:25
    at Array.reduce (<anonymous>)
    at new Renderer (D:\hexotest\test\node_modules\hexo-renderer-markdown-it\lib\renderer.js:39:29)
    at D:\hexotest\test\node_modules\hexo-renderer-markdown-it\index.js:32:18
    at D:\hexotest\test\node_modules\hexo\lib\hexo\index.js:305:14
    at tryCatcher (D:\hexotest\test\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (D:\hexotest\test\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (D:\hexotest\test\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (D:\hexotest\test\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (D:\hexotest\test\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (D:\hexotest\test\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (node:internal/timers:464:21)

it shows that only 'markdown-it-multimd-table' is compatiable with render.js