Candinya / Kratos-Rebirth

一个可爱而现代的 Hexo 主题
GNU General Public License v3.0
609 stars 79 forks source link

【bug回报】插入mermaid图报错 #187

Closed ArcticLampyrid closed 1 year ago

ArcticLampyrid commented 1 year ago

插入mermaid图报错:

ERROR Render HTML failed: index.html
TypeError: /home/xxx/work/repos/blog/node_modules/hexo-theme-kratos-rebirth/layout/layout.ejs:22
    20| 
    21|         <%- partial('_partial/footer') %>
 >> 22|         <%- partial('_partial/after-footer') %>
    23|     </body>
    24| </html>

/home/xxx/work/repos/blog/node_modules/hexo-theme-kratos-rebirth/layout/_partial/after-footer.ejs:36
    34| <!-- Extra support for third-party plguins  -->
    35| <% if (config.mermaid && config.mermaid.enable || theme.mermaid && theme.mermaid.enable) { %>
 >> 36|     <%- partial('../_plugins/mermaid', { mermaidConfig: config.mermaid || theme.mermaid }) %>
    37| <% } %>
    38| 

/home/xxx/work/repos/blog/node_modules/hexo-theme-kratos-rebirth/layout/_plugins/mermaid.ejs:10
    8|     };
    9|     if (typeof mermaid == 'undefined') {
 >> 10|         const src = '<%- url_npm_cdn(`mermaid", "dist/mermaid.min.js`) %>';
    11|         $.getScript(src, init);
    12|     }
    13|     // Set PJAX callback function

Cannot read properties of undefined (reading 'includes')

已经安装

npm install hexo-filter-mermaid-diagrams

主题目录下已经设置

# Mermaid tag
mermaid:
  enable: true
  # Available themes: default | dark | forest | neutral
  theme: forest

插入的代码

sequenceDiagram
    Client->>Server: SYN=1, ack=0, seq=x
    Server->>Client: SYN=1, ack=1, seq=y, ack=x + 1
    Client->>Server: ACK=1, seq=x + 1, ack=y + 1
sequenceDiagram
    Client->>Server: SYN=1, ack=0, seq=x
    Server->>Client: SYN=1, ack=1, seq=y, ack=x + 1
    Client->>Server: ACK=1, seq=x + 1, ack=y + 1

同样的配置 next 主题没有报错,mermaid 图正常显示,请问我的配置出现了问题吗?

Originally posted by @tyokyo320 in https://github.com/Candinya/Kratos-Rebirth/issues/47#issuecomment-1601291901