0%

加入豆瓣电影读书等

一场谋杀案使银行家安迪(蒂姆•罗宾斯 Tim Robbins 饰)蒙冤入狱,谋杀妻子及其情人的指控将囚禁他终生。

一、步骤(Next主题)

  1. 新增电影导航栏

    • hexo new page movies
    • 修改主题下配置文件_config.yml,新增movies项,具体语法见配置说明
    1
    2
    3
    4
    5
    6
    7
    8
    menu:
    home: / || home
    about: /about/ || user
    tags: /tags/ || tags
    categories: /categories/ || th
    archives: /archives/ || archive
    movies: /movies/ || film
    links: /links/ || link
    • 修改themes/next/languages/zh-CN.yml
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    menu:
    home: 首页
    archives: 归档
    categories: 分类
    tags: 标签
    about: 关于
    search: 搜索
    schedule: 日程表
    sitemap: 站点地图
    commonweal: 公益 404
    music: 音乐
    movies: 电影
    links: 友链
  2. 安装插件npm install hexo-douban-card --save

  3. 编辑source/movies/index.md

1
{% douban movie 24745500 %}
  1. hexo s,正常情况下就可以预览了

二、报错

  1. unknown path
1
2
3
FATAL {                                                                                                                 
err: Template render error: (unknown path)
Error: template not found: your_path\node_modules\hexo-douban-card\movieCard.html
  • 跟着官网来操作的,正常不应该出错的,唯一的可能就是版本问题

  • 升级hexo,然后重新初始化一个空的博客,选择next主题,一顿操作下来还是同样的问题

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    hexo: 5.4.0
    hexo-cli: 4.3.0
    os: darwin 19.6.0 10.15.7

    node: 16.6.0
    v8: 9.2.230.21-node.18
    uv: 1.42.0
    zlib: 1.2.11
    brotli: 1.0.9
    ares: 1.17.1
    modules: 93
    nghttp2: 1.44.0
    napi: 8
    llhttp: 6.0.2
    openssl: 1.1.1k
    cldr: 39.0
    icu: 69.1
    tz: 2021a
    unicode: 13.0
  • 既然我遇到了,别人肯定也遇到了,查看官网issue,没有报这个错的

  • 查看官方演示案例,评论区有跟我情况一样的

  • issues,一路跟过去可以发现是渲染器的问题,具体使用地方见node_modules/hexo-douban-card/index.js

  • npm install nunjucks --save

  • npm list --depth=0

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    hexo-site@0.0.0 /your_path/blog
    ├── hexo-algolia@1.3.1
    ├── hexo-deployer-git@3.0.0
    ├── hexo-douban-card@1.2.2
    ├── hexo-generator-archive@0.1.5
    ├── hexo-generator-category@0.1.3
    ├── hexo-generator-index-pin-top@0.2.2
    ├── hexo-generator-searchdb@1.1.0
    ├── hexo-generator-sitemap@2.0.0
    ├── hexo-generator-tag@0.2.0
    ├── hexo-renderer-ejs@0.3.1
    ├── hexo-renderer-marked@2.0.0
    ├── hexo-renderer-stylus@0.3.3
    ├── hexo-server@0.3.3
    ├── hexo-symbols-count-time@0.6.3
    ├── hexo-tag-aplayer@2.0.7
    ├── hexo-tag-cloud@1.0.1
    ├── hexo-wordcount@6.0.1
    ├── hexo@5.4.0
    ├── live2d-widget-model-izumi@1.0.5
    ├── lodash@4.17.21
    └── nunjucks@3.2.3
  • hexo s,依然包错,卸载重新安装

  • npm uninstall nunjucks

  • npm install nunjucks@2.4.2 --save

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    hexo-site@0.0.0 /your_path/blog
    ├── hexo-algolia@1.3.1
    ├── hexo-deployer-git@3.0.0
    ├── hexo-douban-card@1.2.2
    ├── hexo-generator-archive@0.1.5
    ├── hexo-generator-category@0.1.3
    ├── hexo-generator-index-pin-top@0.2.2
    ├── hexo-generator-searchdb@1.1.0
    ├── hexo-generator-sitemap@2.0.0
    ├── hexo-generator-tag@0.2.0
    ├── hexo-renderer-ejs@0.3.1
    ├── hexo-renderer-marked@2.0.0
    ├── hexo-renderer-stylus@0.3.3
    ├── hexo-server@0.3.3
    ├── hexo-symbols-count-time@0.6.3
    ├── hexo-tag-aplayer@2.0.7
    ├── hexo-tag-cloud@1.0.1
    ├── hexo-wordcount@6.0.1
    ├── hexo@5.4.0
    ├── live2d-widget-model-izumi@1.0.5
    ├── lodash@4.17.21
    └── nunjucks@2.4.2
    1
    2
    3
    Unhandled rejection Template render error: (/your_path/blog/themes/next/layout/index.swig)
    Template render error: (your_path/themes/next/layout/_layout.swig) [Line 32, Column 37]
    unexpected token: =
  • npm update nunjucks

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    hexo-site@0.0.0 /your_path/blog
    ├── hexo-algolia@1.3.1
    ├── hexo-deployer-git@3.0.0
    ├── hexo-douban-card@1.2.2
    ├── hexo-generator-archive@0.1.5
    ├── hexo-generator-category@0.1.3
    ├── hexo-generator-index-pin-top@0.2.2
    ├── hexo-generator-searchdb@1.1.0
    ├── hexo-generator-sitemap@2.0.0
    ├── hexo-generator-tag@0.2.0
    ├── hexo-renderer-ejs@0.3.1
    ├── hexo-renderer-marked@2.0.0
    ├── hexo-renderer-stylus@0.3.3
    ├── hexo-server@0.3.3
    ├── hexo-symbols-count-time@0.6.3
    ├── hexo-tag-aplayer@2.0.7
    ├── hexo-tag-cloud@1.0.1
    ├── hexo-wordcount@6.0.1
    ├── hexo@5.4.0
    ├── live2d-widget-model-izumi@1.0.5
    ├── lodash@4.17.21
    └── nunjucks@2.5.2
    1
    2
    3
    Unhandled rejection Template render error: (/your_path/blog/themes/next/layout/index.swig)
    Template render error: (/your_path/blog/themes/next/layout/index.swig)
    Template render error: (/your_path/blog/themes/next/layout/index.swig) [Line 8, Column 10]
  • npm uninstall nunjucks

  • npm install nunjucks --save

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    hexo-site@0.0.0 /your_path/blog
    ├── hexo-algolia@1.3.1
    ├── hexo-deployer-git@3.0.0
    ├── hexo-douban-card@1.2.2
    ├── hexo-generator-archive@0.1.5
    ├── hexo-generator-category@0.1.3
    ├── hexo-generator-index-pin-top@0.2.2
    ├── hexo-generator-searchdb@1.1.0
    ├── hexo-generator-sitemap@2.0.0
    ├── hexo-generator-tag@0.2.0
    ├── hexo-renderer-ejs@0.3.1
    ├── hexo-renderer-marked@2.0.0
    ├── hexo-renderer-stylus@0.3.3
    ├── hexo-server@0.3.3
    ├── hexo-symbols-count-time@0.6.3
    ├── hexo-tag-aplayer@2.0.7
    ├── hexo-tag-cloud@1.0.1
    ├── hexo-wordcount@6.0.1
    ├── hexo@5.4.0
    ├── live2d-widget-model-izumi@1.0.5
    ├── lodash@4.17.21
    └── nunjucks@3.2.3
  • 一顿操作下来好了,不过是临时性的,下次再用还是会报错

  • 尝试npm cache clean --force

  1. 新初始化一个目录则可以,大概是装的插件太多了,有冲突的地方

搁置,使用hexo-douban插件,传送门,有问题见issue

三、参考

  1. hexo-douban-card
  2. issue
  3. issue
  4. nunjucks