Litreily / hexo-theme-snark

An hexo theme with lofter style
https://www.litreily.top
MIT License
73 stars 13 forks source link

Archives 页面无法加载 #9

Closed T-Mux closed 4 years ago

T-Mux commented 4 years ago

执行 hexo s 进行预览

在点击“归档”页面后,终端给出以下报错:


Unhandled rejection TypeError: /Users/tmux/Documents/Blog/themes/snark/layout/archive.pug:19
    17| 
    18|         //Use lodash to classify posts. See https://lodash.com/docs#groupBy
  > 19|         each posts, year in _.groupBy(page.posts.toArray(), function(p){return -p.date.format('YYYY')})
    20|             h2= -year
    21|             ul.list
    22|                 for post in posts

Cannot read property 'groupBy' of undefined
    at eval (eval at wrap (/Users/tmux/Documents/Blog/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:442:17)
    at eval (eval at wrap (/Users/tmux/Documents/Blog/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:546:4)
    at template (eval at wrap (/Users/tmux/Documents/Blog/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:667:72)
    at _View._compiled (/Users/tmux/Documents/Blog/node_modules/hexo/lib/theme/view.js:136:50)
    at _View.render (/Users/tmux/Documents/Blog/node_modules/hexo/lib/theme/view.js:39:17)
    at /Users/tmux/Documents/Blog/node_modules/hexo/lib/hexo/index.js:64:21
    at tryCatcher (/Users/tmux/Documents/Blog/node_modules/bluebird/js/release/util.js:16:23)
    at /Users/tmux/Documents/Blog/node_modules/bluebird/js/release/method.js:15:34
    at RouteStream._read (/Users/tmux/Documents/Blog/node_modules/hexo/lib/hexo/router.js:30:5)
    at RouteStream.Readable.read (_stream_readable.js:475:10)
    at resume_ (_stream_readable.js:962:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Litreily commented 4 years ago

请确认是否已经创建了archives目录和index.md,创建方法参考: https://github.com/Litreily/hexo-theme-snark#add-general-pages

并确保博客目录_posts不为空

T-Mux commented 4 years ago

是的,我已创建archives目录,是用hexo new page "archives"进行的创建

这是我的source文件夹目录:

WX20200811-205049@2x

这是archives文件夹下的index.md内容:

WX20200811-205802@2x

对比您在README文件中提供的source树,发现缺少了source目录下的一个 index.md文件

WX20200811-205126@2x

于是尝试用README文件中提供的代码进行二次覆盖,终端报错

WX20200811-205147@2x

非常头疼,找不到问题出在哪里。是少了source目录下的那个index.md文件造成的吗?

Litreily commented 4 years ago

你说的终端报错是没有关系的,因为你已经存在对应文件夹了,所以实际上也没有替换。source 目录的index.md对应的就是你的主页,如果你主页能正常显示说明是可有可无的,不过你可以手动添加,输入

---
layout: page
title: home
---
Litreily commented 4 years ago

找到问题了,是hexo 5.0.0之后不再支持lodash了,

https://hexo.io/docs/variables#Global-Variables

Lodash has been removed from global variables since Hexo 5.0.0. You-Dont-Need-Lodash-Underscore might be helpful for your migration.

你的hexo应该是5.0.0之后的,我会尽快fix,感谢你的report.

T-Mux commented 4 years ago

非常感谢作者这么上心,期待更新

Litreily commented 4 years ago

@T-Mux 已经fix了,请pull到最新然后再尝试下~

T-Mux commented 4 years ago

@T-Mux 已经fix了,请pull到最新然后再尝试下~

非常感谢,已经解决!我将close这个issue