jerryc127 / hexo-theme-butterfly

🦋 A Hexo Theme: Butterfly
https://butterfly.js.org
Apache License 2.0
6.8k stars 1.24k forks source link

[Feature]: 希望可以兼容一下tags为空的情况 #1501

Open iamxiaojianzheng opened 1 month ago

iamxiaojianzheng commented 1 month ago

想要的功能 | What feature do you want?

我计划从next主题迁移过来,之前写的文档不是所有的都填写了tags属性。

在启用post_meta.page.tags = true && related_post.enable = true时,部署报错。

TypeError: ...\themes\butterfly\layout\post.pug:13
    11|       if (theme.post_meta.post.tags)
    12|         .post-meta__tag-list
  > 13|           each item, index in page.tags.data
    14|             a(href=url_for(item.path)).post-meta__tags #[=item.name]
    15|       include includes/third-party/share/index.pug
    16|

Cannot read properties of undefined (reading 'data')
TypeError: ...\themes\butterfly\layout\post.pug:27
    25|       include includes/pagination.pug
    26|     if theme.related_post && theme.related_post.enable
  > 27|       != related_posts(page,site.posts)
    28|
    29|     if page.comments !== false && theme.comments && theme.comments.use
    30|       - var commentsJsLoad = true

Cannot read properties of undefined (reading 'forEach')
jerryc127 commented 1 month ago

我就是很多写了 tags 然后没有配置内容 并不会报错

你试下跑 hexo clean && hexo g --debug 看看