tea3 / hexo-related-popular-posts

A hexo plugin that generates a list of links to related posts and popular posts. Also , this plugin can get Visitor Counts (PV) on posts.
MIT License
109 stars 14 forks source link

When article was modified, the page could't render again #8

Closed 9monsters closed 5 years ago

9monsters commented 6 years ago

For BUG

Environment Info

OS version

Node version(node -v)

v9.4.0

Your site _config.yml

# Hexo Configuration
## Docs:                     https://hexo.io/docs/configuration.html
## Source:                   https://github.com/hexojs/hexo/

# Site
title:                       鲤鱼 | Erasme
subtitle:                    码农
description:                 鲤鱼 Coder Vue Java
author:                      鲤鱼 | Erasme
language:                    zh-Hans
i18n:
  type: [page, post]
  generator: [index, archive, category, tag]
timezone:                    Asia/Shanghai

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url:                         https://code.aimer.love
root:                        /
permalink:                   :month:day/:title/
permalink_defaults:
    lang:                    zh-Hans

# Directory
source_dir:                  source
public_dir:                  public
tag_dir:                     tags
archive_dir:                 archives
category_dir:                categories
code_dir:                    downloads/code
i18n_dir:                    :lang
skip_render:

# Writing
new_post_name:               :title.md # File name of new posts
default_layout:              post
titlecase:                   false # Transform title into titlecase
external_link:               false # Open external links in new tab
filename_case:               0
render_drafts:               false
post_asset_folder:           true
relative_link:               false
future:                      true
highlight:
  enable:                    true
  line_number:               true
  auto_detect:               true
  tab_replace:               true

# Category & Tag
default_category:            uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format:                 YYYY-MM-DD
time_format:                 HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page:                    20
pagination_dir:              page

# Extensions
## Plugins:                  https://hexo.io/plugins/
## Themes:                   https://hexo.io/themes/
theme:                       yelee

feed:
  type:                      atom
  path:                      atom.xml
  limit:                     20
  hub:

# sitemap:
# path:                      sitemap.xml

baidusitemap:
    path:                    baidusitemap.xml

search:
  path:                      search.xml
  field:                     all

sequence:
  #webfont:                  https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.27/webfontloader.js
  #snap:                     https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.4.1/snap.svg-min.js
  #underscore:               https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js
  #sequence:                 https://cdnjs.cloudflare.com/ajax/libs/js-sequence-diagrams/1.0.6/sequence-diagram-min.js
  # css:                     # optional, the url for css, such as hand drawn theme
  options:
    theme:                   simple
    css_class:

flowchart:
  # raphael:                 # optional, the source url of raphael.js
  # flowchart:               # optional, the source url of flowchart.js
  options:                   # options used for `drawSVG`

bilibili:
  width:                     566
  height:                    846

# hexo-tag-cloud
tag_cloud:
    textFont:                Trebuchet MS, Helvetica
    textColour:              rgb(125,165,189)
    textHeight:              24
    outlineColour:

# Hexo Beautify
beautify:
  types:
    - html
    - css
    - js
  exclude:
    - '*.min.css'
    - '*.min.js'
  html:
    'indent_inner_html':     true
    'indent_size':           2
    'indent_with_tabs':      false
    # More Options (https://github.com/beautify-web/js-beautify/blob/master/README.md)
  css:
    'indent_size':           2
    'newline_between_rules': true
    'indent_with_tabs':      false
    # More Options (https://github.com/beautify-web/js-beautify/blob/master/README.md)
  js:
    'indent_size':           2
    'indent_with_tabs':      false
    # More Options (https://github.com/beautify-web/js-beautify/blob/master/README.md)

thumbnails:
  # masks:
    # - \.jpg$
    # - \.jpeg$
    # - \.png$
    # - \.bmp$
  profiles:
    largeThumb:
      resize:
        - 400
        - 400
      blur:
        - 10
    smallThumb:
      resize:
        - 400
        - 400

markdown_it_plus:
    highlight: true
    html: true
    xhtmlOut: true
    breaks: true
    langPrefix:
    linkify: true
    typographer:
    quotes: “”‘’
    pre_class: highlight
    Katex: true
    plugins:
    # other plugins
        - plugin:
            name: markdown-it-footnote
            enable: true
        - plugin:
            name: hexo-tippy
            enable: true
# tippy:
#   theme_file: tippy-theme.css   # css file containing the theme, relative to blog root directory
#   theme_name: honeybee

lazyload:
  enable: true

# Deployment

Your theme _config.yml

# Theme Version | 当前版本
Yelee: "3.5"

# >>> Basic Setup | 基础设置 <<<

# Header | 主菜单
## About Page: `hexo new page about`
## Tags Cloud Page: `hexo new page tags`
menu:
  主页: /
  所有文章: /archives/
  日迹: /categories/journal/
  标签云: /tags/
  关于我: /about/

# Link to your avatar | 填写头像地址
avatar: /img/avatar.png

# Small icon of Your site | 站点小图标地址
favicon: /apple-touch-icon.png

# Internationalization | 主题语言
## Change Language in SITE's _config.yml | 在站点配置中切换语言
## https://hexo.io/docs/internationalization.html
Available Languages: en, zh-Hans, zh-Hant-TW, zh-Hant-HK

# Subdirectory | 子目录
## If your site' url is 'http://yoursite.com/blog', set root_url as '/blog/'
## 网站若存放在子目录,请按上面格式填写
## https://hexo.io/docs/configuration.html#URL
root_url:

# Year of Site Creation | 网站成立年份
since: 2014

# Social info. Bar | 社交信息展示
## Keep "mailto:" in Email | 设置 Email 时保留 "mailto:"
## Encrypt email 加密邮件地址 http://ctrlq.org/encode/
## RSS requires a plugin to take effect | 使用 RSS 需先安装对应插件
## https://github.com/hexojs/hexo-generator-feed

subnav:
  Email: "mailto:XXXXXX"
  新浪微博: "https://weibo.com/XXXXX"
  GitHub: "https://github.com/yunsu2"
  #V2EX: "#"
  RSS: "/atom.xml"
  知乎: "https://www.zhihu.com/people/XXXXX"
  #豆瓣: "douban"
  简书: "http://www.jianshu.com/users/XXXXX/timeline"
  #SegmentFault: ""
  #博客园: "cnblogs"
  #CSDN: ""
  Coding: "https://coding.net/u/XXXXXXX"
  网易云音乐: "http://music.163.com/#/user/home?id=XXXXX"
  #虾米音乐: "xiami"
  bilibili: "http://space.bilibili.com/XXXXXX/#!/index"
  AcFun: "http://www.acfun.tv/u/XXXXX"
  #niconico: ""
  #Quora: ""
  #Facebook: "#"
  Google: "https://plus.google.com/u/0/XXXXX"
  Twitter: "https://twitter.com/wangjia_1919"
  #LinkedIn: "#"
  QQ: "http://sighttp.qq.com/authd?IDKEY=XXXXXXX"
  微信: "weixin://contacts/profile/XXXXX"
  #PayPal: "#"
  #StackOverflow: "#"
  #CodePen: ""
  #Plunker: ""
  #Instagram: "#"
  #LOFTER: ""
  #Flickr: "#"
  #reddit: ""
  #Medium: ""
  #TiddlyWiki: ""
  #Tumblr: ""
  #_500px: ""

# >>> Conments 评论系统 <<<
# Chose ONE as your comment system and keep others disable.
# 选一个作为网站评论系统,其他保持禁用。

preload_comment: true
## false: 当点击评论条等区域时再加载评论模块
## false: load comment's section until u click/hover on the bar/icon

show_count: true
## 是否在主页文章标题旁显示评论数(多说、Disqus)
## Add comment count after article title

disqus:
  #on: true
  shortname:
  # https://help.disqus.com/customer/en/portal/articles/466208-what-s-a-shortname-
  # It is unnecessary to enable disqus here if
  # you have set "disqus_shortname" in your site's "_config.yml"

duoshuo:
  on: false
  domain: XXXXX
  # 是否开启多说评论,http://duoshuo.com/create-site/
  # 使用上面网址登陆你的多说,然后创建站点,在 domain 中填入你设定的域名前半部分
  # http://<要填的部分>.duoshuo.com (domain只填上<>里的内容,不要填整个网址)

youyan:
  on: true
  id: XXXXXX
  # 是否开启友言评论,http://www.uyan.cc/index.php
  # id 中填写你的友言用户数字ID,注册后进入后台管理即可查看
  # 友言服务在 Web 环境下运行,普通本地环境无法查看,请部署后在线上测试。

# >>> Style Customisation 样式自定义 <<<

# Background | 背景
## "5": show images form bg-1.jpg to bg-5.jpg in `/yelee/source/background/`
## "5": 显示`/yelee/source/background/`文件夹中 bg-1.jpg 到 bg-5.jpg 这5张图片
## "0": white-gray background | 淳朴灰白背景
background_image: 11

# Base Font Size | 字号调节
base_font_size: 16  #px, 16 - 24

## General Color Scheme | 主题配色方案
## 可用值 Value: yilia
color_scheme:

highlight_style:
  #on: true
  inline_code: 1  # Value: 0 - 9 可选
  code_block: 1  # Value: 0 - 4
  # Set inline_code to style highlight text
  # Chose a highlight theme for code block
  # 通过 inline_code 切换内置文本高亮样式
  # 通过 code_block 切换内置代码高亮配色主题

blockquote_style:
  #on: true
  blockquote: 2 # Value: 0 - 7 可选
  # 自定义文章「引用部分」的样式

# Headings Style | 标题风格
## 0-Yelee, 1-Yilia, 2-GitHub
heading_style: 0 # Value: 0 - 2

## List style type (ul) | 无序列表项标记样式
list_style: 0  # value: 0 - 12 可选

# 左边栏宽度 px
left_col_width: 384

# Copyright info. of post | 文末版权信息
copyright: true

# Table of contents | 文章目录
toc:
  on: true
  list_number: true # 目录序号
  max_depth: 4  # 1 - 6 (h1-h6) 目录最大级数
  nowrap: false # Keep title on same line | 目录标题不换行

# 是否开启主页及加载头像时的动画效果
# Animation in Homepage and Loading avatar
animate: true

# Load jQuery UI to style tooltips
# 工具提示框样式美化
jquery_ui: true

# Max width of right cloumn | 限制右侧内容的宽带
limit_article_width:
  on: false
  max_width: 60 # em

# >>> Small features | 小功能设置 <<<

# 是否开启边栏多标签切换
# Birdhouse button in left column
tagcloud: true

# Blogroll, Link exchange | 友情链接
friends:
  Hexo: https://hexo.io
  GitHub: https://pages.github.com/
  MOxFIVE: http://moxfive.xyz/
#friends: false

#是否开启“关于我”。
aboutme: Java WEB
#aboutme: false

# Open link in a new tab | 是否在新窗口打开链接
## `global` 0: Set separately, 1: Open all in new 2: Open all in current
## `global` 0: 分开设置, 1: 全部在新标签打开, 2: 全部在"当前"标签打开
open_in_new:
  global: 0 # 0-2
  title: false # article title in homepage 主页文章标题
  post: true # link within post/page 正文中的链接
  tags: true # 标签
  categories: true # 分类
  article_nav: false # 导航
  archives: true # 归档
  mini_archives: true # 迷你归档
  menu: false # 边栏菜单
  friends: true  # 友情链接
  socail: true # 社交图标

# Customize feed link 自定义订阅地址
rss: /atom.xml

# Update Reminder for IE6/7/8
# 针对 IE6/7/8 的升级浏览器提示
ie_updater:
  on: true
  link: //outdatedbrowser.com/
  ## http://browsehappy.com/
  ## http://outdatedbrowser.com/

# Tab Title Change | 标签页标题切换
tab_title_change:
  on: true
  left_tab_title: '(つェ⊂) 我藏好了哦~ '
  return_tab_title: '(*´∇`*) 被你发现啦~ '

# >>> Vendors | 第三方工具 & 服务 <<<

# Local Site Search | 本地站内搜索
## Insatall below plugin to take effect | 使用搜索需先安装对应插件
## https://github.com/PaicHyperionDev/hexo-generator-search
search:
  on: true
  onload: true
  ## true: get search.xml file when the page has loaded
  ## false: get the file when search box gets focus

# images viewer | 图片浏览器
## http://www.fancyapps.com/fancybox/
fancybox: true

# Display Math(LaTeX, MathML...) | 数学公式支持
## https://www.mathjax.org/
mathjax: true

# Socail Share | 是否开启分享
share:
  on: true
  baidu: true
  addthis: true
  addthis_pubid: "XXXXXXXX"
  ## Go to www.addthis.com/dashboard to get your pubid (in src of Code)
  ## and customize AddThis share buttons

# 百度、谷歌站长验证。填写 HTML 标签 content
# Site Verification for Google and Baidu. HTML label content.
baidu_site: XXXXXX
google_site:

# Fill in Google Analytics tracking ID, #e.g. UA-XXXXX-X
google_analytics:

# 百度统计 http://sitecenter.baidu.com/sc-web/
# 查看代码,填入 //hm.baidu.com/hm.js? 之后的内容
baidu_tongji: 00bd9d7f270b52b3b20810ad604f5d41

# 不蒜子网站计数设置
# http://ibruce.info/2015/04/04/busuanzi/
visit_counter:
  on: true
  site_visit: true
  page_visit: true

# GitHub Repo Widget
# https://github.com/hustcc/GitHub-Repo-Widget.js
github_widget: true

# Progress Bar | 页面加载进度条
# Demo: http://github.hubspot.com/pace/docs/welcome/
# type: barber-shop|big-counter|bounce|center-atom|center-circle|
#       center-radar|center-simple|corner-indicator|flash|flat-top|
#       loading-bar|mac-osx|minimal
# color: black|blue|green|orange|pink|purple|red|silver|white|yellow|
progressBar:
  on: true
  type: "minimal"  # Keep Quotes | 保留引号避免出错
  color: blue

github_history:
    blame: https://github.com/yunsu2/yunsu2.github.io/blame/develop/source/_posts/
    commits: https://github.com/yunsu2/yunsu2.github.io/commits/develop/source/_posts/
    raw: https://raw.githubusercontent.com/yunsu2/yunsu2.github.io/develop/source/_posts/

github_theme_url:
    yelee: https://github.com/yunsu2/hexo-theme-yelee

bgFlower:
    on: false

CDN:
  jquery: //cdn.bootcss.com/jquery/2.2.4/jquery.min.js
  require: //cdn.bootcss.com/require.js/2.2.0/require.min.js
  fontawesome: //cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css
  fancybox_js: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js
  fancybox_css: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css
  animate_css: //cdn.bootcss.com/animate.css/3.5.1/animate.min.css
  jquery_ui_js: //cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js
  jquery_ui_css: //cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css
  pace_js: //cdn.bootcss.com/pace/1.0.2/pace.min.js
  clipboard: //cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js
  mathjax: //cdn.bootcss.com/mathjax/2.6.1/MathJax.js
  scrollreveal: //cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js

Plugin version(npm ls --depth 0)

hexo-site@0.0.1 /Users/Erasme/docs/yunsu2.github.io
├── hexo@3.4.4
├── hexo-beautify@1.0.2
├── hexo-blog-encrypt@2.0.3
├── hexo-deployer-git@0.3.1
├── hexo-filter-flowchart@1.0.4
├── hexo-filter-plantuml@1.0.1
├── hexo-filter-sequence@1.0.3
├── hexo-fs@0.2.2
├── hexo-generator-archive@0.1.5
├── hexo-generator-baidu-sitemap@0.1.2
├── hexo-generator-category@0.1.3
├── hexo-generator-feed@1.2.2
├── hexo-generator-index@0.2.1
├── hexo-generator-search@1.0.4
├── hexo-generator-seo-friendly-sitemap@0.0.19
├── hexo-generator-sitemap@1.2.0
├── hexo-generator-tag@0.2.0
├── hexo-i18n@0.2.1
├── hexo-lazyload@1.0.3
├── hexo-migrator-rss@0.1.4
├── hexo-pagination@0.1.0
├── hexo-pdf@1.1.1
├── hexo-related-popular-posts@3.0.0
├── hexo-renderer-ejs@0.2.0
├── hexo-renderer-markdown-it-plus@1.0.2
├── hexo-renderer-stylus@0.3.3
├── hexo-renderer-webpack@0.4.0
├── hexo-server@0.2.2
├── hexo-tag-bilibili@0.2.1
├── hexo-tag-cloud@2.0.9
├── hexo-tag-plantuml@1.0.0
├── hexo-thumbnails@0.0.6
├── hexo-tippy@0.1.3
├── hexo-util@0.6.3
└── markdown-it-footnote@3.0.1
tea3 commented 6 years ago

@yunsu2 Thank you for report me in detail. Sonrry , I tried to occur same problem. but it did'nt occur. The environment I tried is as follows.

$ nvm install v9.4.0
$ nvm use v9.4.0
$ npm install hexo-cli
$ hexo new hexo94
$ cd hexo94
$ npm uninstall hexo --save
$ npm install hexo@3.4.4 --save
$ npm install hexo-related-popular-posts --save
$ git clone https://github.com/MOxFIVE/hexo-theme-yelee.git themes/yelee

Next , I edited theme (article.ejs) as follows.

<article id="<%= post.layout %>-<%= post.slug %>" class="article article-type-<%= post.layout %>" itemscope itemprop="blogPost">
  <%if(post.noDate != "true"){%>
    <div class="article-meta">
      <%- partial('post/date', {class_name: 'article-date', date_format: null}) %>
    </div>
  <%}%>
  <div class="article-inner">
    <% if (theme.fancybox){ %>
      <input type="hidden" class="isFancy" />
    <% } %>
    <% if (post.link || post.title){ %>
      <header class="article-header">
        <%- partial('post/title', {class_name: 'article-title'}) %>
      </header>
      <% if (!index){ %>
      <div class="article-info article-info-post">
        <%- partial('post/category') %>
        <%- partial('post/tag') %>
        <div class="clearfix"></div>
      </div>
      <% } %>
    <% } %>
    <div class="article-entry" itemprop="articleBody">
      <% if (index && (post.description || post.excerpt)){ %>
          <% if (post.description){ %>
              <%- post.description %>
          <% } else { %>
              <%- post.excerpt %>
          <% } %>
      <% } else { %>
          <% if (is_page()){ %>
              <%- partial('_partial/page') %>
          <% } %>
        <%- post.content %>
      <% } %>
    </div>

<!-- I added plugin's code as follows -->
    <div>
      <%-
        popular_posts( {} , post )
      %>
    </div>

    <% if (index){ %>
    <div class="article-info article-info-index">
      <%if(post.top){%>
        <div class="article-pop-out tagcloud">
          <a class="">置顶</a>
        </div>
      <% } %>
      <%- partial('post/category') %>
      <%- partial('post/tag') %>
      <% if (index && (post.description || post.excerpt)){ %>
        <p class="article-more-link">
          <a href="<%- url_for(post.path) %>#more"><%= __('index.more') %> >></a>
        </p>
      <% } %>
      <div class="clearfix"></div>
    </div>
    <% } %>
  </div>
  <% if (!index){ %>
    <%- partial('post/nav') %>
  <% } %>
</article>
<%- partial('_partial/toc') %>

<% if (!index && theme.share.on && (post.share != false || post.share)){ %>
    <%- partial('post/share') %>
<% } %>

<% if (!index && post.comments){ %>
    <% if (theme.duoshuo.on) { %>
      <%- partial('comments/duoshuo', {
          key: post.path,
          title: post.title,
          url: config.url+url_for(post.path),
          }) %>
    <% } else if (theme.youyan.on) { %>
        <%- partial('comments/youyan') %>
    <% } else if (theme.disqus.on) { %>
        <%- partial('comments/disqus', {
            shortname: theme.disqus.shortname
          }) %>
    <% } else if (config.disqus_shortname) { %>
        <%- partial('comments/disqus', {
            shortname: config.disqus_shortname
          }) %>
    <% } %>
<% } %>

<%- partial('_partial/post-nav-button') %>

<% if (!index) { %>
    <script>
        <% if (post.fancybox === false){ %>
            yiliaConfig.fancybox = false;
        <% } %>
    </script>
<% } %>

Finally , I created a new article or edited else article.

I'll take a closer look at it. Can you recover with the next command for the time being ?

$ hexo clean
$ hexo s

Also , errors occurred in the following position. https://github.com/tea3/hexo-related-popular-posts/blob/master/lib/collector.js#L192

If errors occur, please tell me the detailed information with the following code.

console.log(`gaData[i]:`)
console.log(gaData[i])
console.log(`post:`)
console.log(post)
9monsters commented 5 years ago

Thank you, I check my config and done well