theme-next / hexo-theme-next

Elegant and powerful theme for Hexo.
https://theme-next.org
Other
8.17k stars 2.05k forks source link

Multiple posts could not contain a same tag (TypeError: this.localeData(...).postformat is not a function) #1690

Closed hushanjushi closed 2 years ago

hushanjushi commented 2 years ago

Please follow this Issue template to provide relevant information, such as source code repositories, blog links, and screenshots, which will help us investigate. 请按照此 Issue 模版提供相关信息,例如源码仓库、博客链接和屏幕截图,这将有助于我们进行调查。

Issue Checklist


Expected behavior

tags和categories均可有多个并在tags里被tagcloud被排序

Actual behavior

a.md title: a date: 2022-01-23 17:02:27 tags: [a,b,c] b.md title: a date: 2022-01-23 17:02:27 tags: [a,b,c] a,b,c应被排序并正常输出,但实际只排序,未正常生成a、b post。 已确认是由于hexo-related-popular-posts无人维护导致某些函数已经无法运行,建议从next中删除 ERROR Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 36, Column 25] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 26, Column 14] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\head\head-unique.njk) [Line 13, Column 12] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 3, Column 3] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\header\index.njk) [Line 6, Column 15] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 5, Column 3] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\header\sub-menu.njk) [Line 2, Column 29] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\header\sub-menu.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 9, Column 12] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_macro\post.njk) [Line 96, Column 16] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\post\post-related.njk) TypeError: this.localeData(...).postformat is not a function at Object._prettifyError (C:\Users\a\Documents\code\Blog\blog\node_modules\nunjucks\src\lib.js:36:11) at C:\Users\a\Documents\code\Blog\blog\node_modules\nunjucks\src\environment.js:563:19 at Template.root [as rootRenderFunc] (eval at _compile (C:\Users\a\Documents\code\Blog\blog\node_modules\nunjucks\src\environment.js:633:18), <anonymous>:45:3) at Template.render (C:\Users\a\Documents\code\Blog\blog\node_modules\nunjucks\src\environment.js:552:10) at C:\Users\a\Documents\code\Blog\blog\node_modules\hexo\lib\plugins\renderer\nunjucks.js:67:37 at _View._compiled (C:\Users\a\Documents\code\Blog\blog\node_modules\hexo\lib\theme\view.js:136:50) at _View.render (C:\Users\a\Documents\code\Blog\blog\node_modules\hexo\lib\theme\view.js:39:17) at C:\Users\a\Documents\code\Blog\blog\node_modules\hexo\lib\hexo\index.js:64:21 at tryCatcher (C:\Users\a\Documents\code\Blog\blog\node_modules\bluebird\js\release\util.js:16:23) at C:\Users\a\Documents\code\Blog\blog\node_modules\bluebird\js\release\method.js:15:34 at RouteStream._read (C:\Users\a\Documents\code\Blog\blog\node_modules\hexo\lib\hexo\router.js:47:5) at RouteStream.Readable.read (node:internal/streams/readable:487:10) at resume_ (node:internal/streams/readable:988:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) ERROR Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 36, Column 25] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 26, Column 14] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\head\head-unique.njk) [Line 13, Column 12] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 3, Column 3] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\header\index.njk) [Line 6, Column 15] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 5, Column 3] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\header\sub-menu.njk) [Line 2, Column 29] Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\_partials\header\sub-menu.njk) Template render error: (C:\Users\a\Documents\code\Blog\blog\themes\next\layout\post.njk) [Line 9, Column 12] at RouteStream.Readable.read (node:internal/streams/readable:487:10) at resume_ (node:internal/streams/readable:988:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)

Steps to reproduce the behavior

  1. 将a.md和b.md 放在source/_post里
  2. hexo g
  3. 出现报错

Environment Information

Node.js and NPM Information

node v16.13.2
npm 8.1.2

Package dependencies Information

hexo-site@0.0.0 C:\Users\a\Documents\code\Blog\blog
├── hexo-deployer-git@3.0.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@2.0.0
├── hexo-generator-searchdb@1.4.0
├── hexo-generator-sitemap@2.2.0
├── hexo-generator-tag@1.0.0
├── hexo-related-popular-posts@5.0.1
├── hexo-renderer-ejs@2.0.0
├── hexo-renderer-pandoc@0.3.0
├── hexo-renderer-stylus@2.0.1
├── hexo-server@3.0.0
├── hexo-theme-landscape@0.0.3
├── hexo-word-counter@0.0.3
└── hexo@6.0.0

Hexo Configuration

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

# Site
title: 1
subtitle: 
description: 
keywords: 
author: 1
language: zh-CN
timezone: Asia/Shanghai

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://example.com
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# 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:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: true
marked:
  prependRoot: true
  postAsset: true
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ''

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# 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
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

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

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next
Plugins: 
- hexo-generator-sitemap

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: git
  repo: https://github.com/hushanjushi/hushanjushi.github.io
  branch: master

search:
  path: search.xml
  field: post
  content: true
  format: html

sitemap:
  path: sitemap.xml
  template: ./sitemap_template.xml
  rel: false
  tags: true
  categories: true

NexT Configuration

cache:
  enable: true

# Remove unnecessary files after hexo generate.
minify: true

# Define custom file paths.
# Create your custom files in site directory `source/_data` and uncomment needed files below.
custom_file_path:
  #head: source/_data/head.njk
  #header: source/_data/header.njk
  #sidebar: source/_data/sidebar.njk
  #postMeta: source/_data/post-meta.njk
  #postBodyEnd: source/_data/post-body-end.njk
  #footer: source/_data/footer.njk
  #bodyEnd: source/_data/body-end.njk
  #variable: source/_data/variables.styl
  #mixin: source/_data/mixins.styl
  #style: source/_data/styles.styl

# ---------------------------------------------------------------
# Scheme Settings
# ---------------------------------------------------------------

# Schemes
#scheme: Muse
#scheme: Mist
scheme: Pisces
#scheme: Gemini

# Dark Mode
darkmode: false

# ---------------------------------------------------------------
# Site Information Settings
# ---------------------------------------------------------------

favicon:
  small: /images/favicon-16x16-next.png
  medium: /images/favicon-32x32-next.png
  apple_touch_icon: /images/apple-touch-icon-next.png
  safari_pinned_tab: /images/logo.svg
  #android_manifest: /manifest.json

# Custom Logo (Warning: Do not support scheme Mist)
custom_logo: #/uploads/custom-logo.jpg

# Creative Commons 4.0 International License.
# See: https://creativecommons.org/about/cclicenses/
creative_commons:
  # Available values: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | cc-zero
  license: by-nc-sa
  # Available values: big | small
  size: small
  sidebar: false
  post: false
  # You can set a language value if you prefer a translated version of CC license, e.g. deed.zh
  # CC licenses are available in 39 languages, you can find the specific and correct abbreviation you need on https://creativecommons.org
  language: 

# ---------------------------------------------------------------
# Menu Settings
# ---------------------------------------------------------------

# Usage: `Key: /link/ || icon`
# Key is the name of menu item. If the translation for this item is available, the translated text will be loaded, otherwise the Key name will be used. Key is case-sensitive.
# Value before `||` delimiter is the target link, value after `||` delimiter is the name of Font Awesome icon.
# External url should start with http:// or https://
menu:
  home: / || fa fa-home
  #about: /about/ || fa fa-user
  tags: /tags/ || fa fa-tags
  categories: /categories/ || fa fa-th
  archives: /archives/ || fa fa-archive
  #schedule: /schedule/ || fa fa-calendar
  #sitemap: /sitemap.xml || fa fa-sitemap
  #commonweal: /404/ || fa fa-heartbeat

# Enable / Disable menu icons / item badges.
menu_settings:
  icons: true
  badges: false

# ---------------------------------------------------------------
# Sidebar Settings
# See: https://theme-next.js.org/docs/theme-settings/sidebar
# ---------------------------------------------------------------

sidebar:
  # Sidebar Position.
  position: left
  #position: right

  # Manual define the sidebar width. If commented, will be default for:
  # Muse | Mist: 320
  # Pisces | Gemini: 240
  #width: 300

  # Sidebar Display (only for Muse | Mist), available values:
  #  - post    expand on posts automatically. Default.
  #  - always  expand for all pages automatically.
  #  - hide    expand only when click on the sidebar toggle icon.
  #  - remove  totally remove sidebar including sidebar toggle.
  display: post

  # Sidebar padding in pixels.
  padding: 18
  # Sidebar offset from top menubar in pixels (only for Pisces | Gemini).
  offset: 12

# Sidebar Avatar
avatar:
  # Replace the default image and set the url here.
  url: /images/1.jpg
  # If true, the avatar will be displayed in circle.
  rounded: true
  # If true, the avatar will be rotated with the cursor.
  rotated: false
site_state: true

# Social Links
# Usage: `Key: permalink || icon`
# Key is the link label showing to end users.
# Value before `||` delimiter is the target permalink, value after `||` delimiter is the name of Font Awesome icon.
social:
  #GitHub: https://github.com/yourname || fab fa-github
  #E-Mail: mailto:yourname@gmail.com || fa fa-envelope
  #Weibo: https://weibo.com/yourname || fab fa-weibo
  #Google: https://plus.google.com/yourname || fab fa-google
  #Twitter: https://twitter.com/yourname || fab fa-twitter
  #FB Page: https://www.facebook.com/yourname || fab fa-facebook
  #StackOverflow: https://stackoverflow.com/yourname || fab fa-stack-overflow
  #YouTube: https://youtube.com/yourname || fab fa-youtube
  #Instagram: https://instagram.com/yourname || fab fa-instagram
  #Skype: skype:yourname?call|chat || fab fa-skype

social_icons:
  enable: true
  icons_only: false
  transition: false

# Blog rolls
links_settings:
  icon: fa fa-globe
  title: Links
  # Available values: block | inline
  layout: block

links:
  #Title: https://example.com

# Table of Contents in the Sidebar
# Front-matter variable (nonsupport wrap expand_all).
toc:
  enable: true
  # Automatically add list number to toc.
  number: true
  # If true, all words will placed on next lines if header width longer then sidebar width.
  wrap: false
  # If true, all level of TOC in a post will be displayed, rather than the activated part of it.
  expand_all: false
  # Maximum heading depth of generated toc.
  max_depth: 6

# ---------------------------------------------------------------
# Footer Settings
# See: https://theme-next.js.org/docs/theme-settings/footer
# ---------------------------------------------------------------

# Show multilingual switcher in footer.
language_switcher: false

footer:
  # Specify the year when the site was setup. If not defined, current year will be used.
  since: 2021

  # Icon between year and copyright info.
  icon:
    # Icon name in Font Awesome. See: https://fontawesome.com/icons
    name: fa fa-heart
    # If you want to animate the icon, set it to true.
    animated: false
    # Change the color of icon, using Hex Code.
    color: "#ff0000"

  # If not defined, `author` from Hexo `_config.yml` will be used.
  copyright:

  # Powered by Hexo & NexT
  powered: true

  # Beian ICP and gongan information for Chinese users. See: https://beian.miit.gov.cn, http://www.beian.gov.cn
  beian:
    enable: false
    icp:
    # The digit in the num of gongan beian.
    gongan_id:
    # The full num of gongan beian.
    gongan_num:
    # The icon for gongan beian. See: http://www.beian.gov.cn/portal/download
    gongan_icon_url:

# ---------------------------------------------------------------
# Post Settings
# See: https://theme-next.js.org/docs/theme-settings/posts
# ---------------------------------------------------------------

# Automatically excerpt description in homepage as preamble text.
excerpt_description: true

# Read more button
# If true, the read more button will be displayed in excerpt section.
read_more_btn: true

# Post meta display settings
post_meta:
  item_text: true
  created_at: true
  updated_at:
    enable: true
    another_day: true
  categories: true

# Post wordcount display settings
# Dependencies: https://github.com/next-theme/hexo-word-counter
symbols_count_time:
  separated_meta: true
  item_text_total: false

# Use icon instead of the symbol # to indicate the tag at the bottom of the post
tag_icon: true

# Donate (Sponsor) settings
# Front-matter variable (nonsupport animation).
reward_settings:
  # If true, a donate button will be displayed in every article by default.
  enable: false
  animation: false
  #comment: Buy me a coffee

reward:
  #wechatpay: /images/wechatpay.png
  #alipay: /images/alipay.png
  #paypal: /images/paypal.png
  #bitcoin: /images/bitcoin.png

# Subscribe through Telegram Channel, Twitter, etc.
# Usage: `Key: permalink || icon` (Font Awesome)
follow_me:
  #Twitter: https://twitter.com/username || fab fa-twitter
  #Telegram: https://t.me/channel_name || fab fa-telegram
  #WeChat: /images/wechat_channel.jpg || fab fa-weixin
  #RSS: /atom.xml || fa fa-rss

# Related popular posts
# Dependencies: https://github.com/tea3/hexo-related-popular-posts
related_posts:
  enable: true
  title: 有关文章
  display_in_home: false
  params:
    maxCount: 5
    #PPMixingRate: 0.0
    isDate: true
    #isImage: false
    #isExcerpt: false

# Post edit
# Easily browse and edit blog source code online.
post_edit:
  enable: false
  url: https://github.com/user-name/repo-name/tree/branch-name/subdirectory-name/ # Link for view source
  #url: https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name/ # Link for fork & edit

# Show previous post and next post in post footer if exists
# Available values: left | right | false
post_navigation: left

# ---------------------------------------------------------------
# Custom Page Settings
# See: https://theme-next.js.org/docs/theme-settings/custom-pages
# ---------------------------------------------------------------

# TagCloud settings for tags page.
tagcloud:
  min: 12 # Minimum font size in px
  max: 30 # Maximum font size in px
  amount: 200 # Total amount of tags
  orderby: name # Order of tags
  order: 1 # Sort order

# Google Calendar
# Share your recent schedule to others via calendar page.
calendar:
  calendar_id: <required> # Your Google account E-Mail
  api_key: <required>
  orderBy: startTime
  showLocation: false
  offsetMax: 72 # Time Range
  offsetMin: 4 # Time Range
  showDeleted: false
  singleEvents: true
  maxResults: 250

# ---------------------------------------------------------------
# Misc Theme Settings
# See: https://theme-next.js.org/docs/theme-settings/miscellaneous
# ---------------------------------------------------------------

# Preconnect CDN for fonts and plugins.
# For more information: https://www.w3.org/TR/resource-hints/#preconnect
preconnect: true
math:
  # Default (false) will load mathjax / katex script on demand.
  # That is it only render those page which has `mathjax: true` in front-matter.
  # If you set it to true, it will load mathjax / katex script EVERY PAGE.
  every_page: false

  mathjax:
    enable: true
    # Available values: none | ams | all
    tags: ams

  katex:
    enable: false
    # See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
    copy_tex: false

# Easily enable fast Ajax navigation on your website.
# For more information: https://github.com/next-theme/pjax
pjax: false

# FancyBox is a tool that offers a nice and elegant way to add zooming functionality for images.
# For more information: https://fancyapps.com/fancybox/
fancybox: true

# A JavaScript library for zooming images like Medium.
# Warning: Do not enable both `fancybox` and `mediumzoom`.
# For more information: https://medium-zoom.francoischalifour.com
mediumzoom: false

# Vanilla JavaScript plugin for lazyloading images.
# For more information: https://apoorv.pro/lozad.js/demo/
lazyload: true

# Pangu Support
# For more information: https://github.com/vinta/pangu.js
# Server-side plugin: https://github.com/next-theme/hexo-pangu
pangu: true

# Quicklink Support
# For more information: https://getquick.link
# Front-matter variable (nonsupport home archive).
quicklink:
  enable: false

  # Home page and archive page can be controlled through home and archive options below.
  # This configuration item is independent of `enable`.
  home: false
  archive: false

  # Default (true) will initialize quicklink after the load event fires.
  delay: true
  # Custom a time in milliseconds by which the browser must execute prefetching.
  timeout: 100
  # Default (true) will attempt to use the fetch() API if supported (rather than link[rel=prefetch]).
  priority: true

# ---------------------------------------------------------------
# Comments Settings
# See: https://theme-next.js.org/docs/third-party-services/comments
# ---------------------------------------------------------------

# Multiple Comment System Support
comments:
  # Available values: tabs | buttons
  style: tabs
  # Choose a comment system to be displayed by default.
  # Available values: disqus | disqusjs | changyan | livere | gitalk | utterances
  active: gitalk
  # Setting `true` means remembering the comment system selected by the visitor.
  storage: true
  # Lazyload all comment systems.
  lazyload: true
  # Modify texts or order for any naves, here are some examples.
  nav:
local_search:
  enable: auto
  # If auto, trigger search by changing input.
  # If manual, trigger search by pressing enter key or search button.
  trigger: auto
  # Show top n results per article, show all results by setting to -1
  top_n_per_article: 1
  # Unescape html strings to the readable one.
  unescape: false
  # Preload the search data when the page loads.
  preload: false

Other Information

System: Win11 22000.438 Screenshot:

image

我觉得和这个问题很像,但是这个插件似乎是自动引入的。。。https://github.com/tea3/hexo-related-popular-posts/issues/31

welcome[bot] commented 2 years ago

Thanks for opening this issue, maintainers will get back to you as soon as possible!

hushanjushi commented 2 years ago

就是hexo-related-popular-posts这个插件的问题,它已经没人维护了

hushanjushi commented 2 years ago

很好,我解决了它,按https://theme-next.js.org/docs/theme-settings/posts.html#Related-Popular-Posts里的相反步骤把hexo-related-popular-posts关掉就行了