Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please Integrate function "Article Updated Date" as Default #15

Closed
3 tasks done
pplmx opened this issue May 31, 2020 · 23 comments
Closed
3 tasks done

Please Integrate function "Article Updated Date" as Default #15

pplmx opened this issue May 31, 2020 · 23 comments
Labels
Bug Something isn't working Discussion Hexo Solved
Projects

Comments

@pplmx
Copy link

pplmx commented May 31, 2020

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

  • I am using the latest version of NexT.
  • I have read the relevant documents of Hexo and NexT.
  • I have reviewed the latest Roadmap on GitHub and searched for current issues, which does not help me.

Expected behavior

If the markdown file was updated, the article can show the update time basing file modified time as default.

@pplmx pplmx added the Feature Request New feature or request label May 31, 2020
@welcome
Copy link

welcome bot commented May 31, 2020

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

@aixiu
Copy link

aixiu commented Jun 1, 2020

这个改为默认不太好吧,更新日期大多数人习惯,且 hexo _config设置文件里有设置更新日期的选项,不建议直接更新在主题里。

或是:
next _config.yml

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

updated_at: enable: true

或是:

hexo _config.yml

index_generator:
  path: ''
  per_page: 5  
  order_by: -date   #可选 -updated 更新日期排列

可以解决你所需问题。

@stevenjoezhang
Copy link
Member

@pplmx
Copy link
Author

pplmx commented Jun 1, 2020

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

I had set these config, but it didn't work. Does any other plugin need to be installed?

I mean my blog article doesn't have update time info. https://blog.caoyu.info/

  • If the theme support this feature, how to configure it?
  • If not support, can we integrate it as default feature?

@stevenjoezhang
Copy link
Member

stevenjoezhang commented Jun 1, 2020

Nope, no other plugins required. Try

another_day: false

@pplmx
Copy link
Author

pplmx commented Jun 1, 2020

It not work

@stevenjoezhang
Copy link
Member

This means that Hexo cannot read the updated time of the article correctly. If you want to get help from others, please provide your environment information, such as operating system, Node.js version, Hexo version, etc.

@stevenjoezhang stevenjoezhang added Bug Something isn't working and removed Feature Request New feature or request labels Jun 1, 2020
@pplmx
Copy link
Author

pplmx commented Jun 1, 2020

FYI.

λ npx hexo -v
hexo: 4.2.1
hexo-cli: 3.1.0
os: Windows_NT 10.0.17763 win32 x64
node: 13.5.0
v8: 7.9.317.25-node.23
uv: 1.34.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.15.0
modules: 79
nghttp2: 1.40.0
napi: 5
llhttp: 2.0.1
openssl: 1.1.1d
cldr: 36.0
icu: 65.1
tz: 2019c
unicode: 12.1


λ cat package.json
{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "4.2.1"
  },
  "dependencies": {
    "hexo": "4.2.1",
    "hexo-baidu-url-submit": "0.0.6",
    "hexo-deployer-git": "^2.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-baidu-sitemap": "^0.1.6",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-feed": "^2.2.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-searchdb": "^1.3.0",
    "hexo-generator-sitemap": "^2.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-helper-live2d": "^3.1.1",
    "hexo-pwa": "git+https://github.com/mystic-cg/hexo-pwa.git",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-server": "^1.0.0",
    "hexo-symbols-count-time": "^0.7.1",
    "live2d-widget-model-koharu": "^1.0.5",
    "live2d-widget-model-z16": "^1.0.5",
    "npm-check-updates": "^6.0.1"
  }
}

@aixiu
Copy link

aixiu commented Jun 1, 2020

试试:
hexo _config.yml

index_generator:
  path: ''
  per_page: 5  
  order_by:  -updated

重新hexo clean hexo g hexo s
这个是可以实现的。

@pplmx
Copy link
Author

pplmx commented Jun 1, 2020

@aixiu
即使更改了order_by: -updated,依然是一样的

@aixiu
Copy link

aixiu commented Jun 2, 2020

@mysit-cg 我是经过测试了,改为order_by: -updated,并依次更新了本地测试正常。

 hexo -v && node -v
hexo: 4.2.0
hexo-cli: 3.1.0
os: Windows_NT 6.1.7601 win32 x64
node: 12.16.1
v8: 7.8.279.23-node.31
uv: 1.34.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.15.0
modules: 72
nghttp2: 1.40.0
napi: 5
llhttp: 2.0.4
http_parser: 2.9.3
openssl: 1.1.1d
cldr: 35.1
icu: 64.2
tz: 2019c
unicode: 12.1
v12.16.1

并且,

$ npm ls --depth 0
hexo-site@0.0.0 E:\My_blog
+-- hexo@4.2.0
+-- hexo-abbrlink@2.0.5
+-- hexo-baidu-url-submit@0.0.6
+-- hexo-deployer-git@2.1.0
+-- hexo-generator-archive@1.0.0
+-- hexo-generator-baidu-sitemap@0.1.6
+-- hexo-generator-category@1.0.0
+-- hexo-generator-feed@2.2.0
+-- hexo-generator-index@1.0.0
+-- hexo-generator-searchdb@1.3.0
+-- hexo-generator-sitemap@2.0.0
+-- hexo-generator-tag@1.0.0
+-- hexo-next-tag@0.3.0 (github:theme-next/hexo-next-tag#095ca82d63db8e6e5231fa9a811d3d68f3d8cc88)
+-- hexo-next-title@0.1.0 (github:theme-next/hexo-next-title#34aff1125fe990f87cb80e148f2c9dfa43f3eb84)
+-- hexo-next-utteranc@1.0.0 (github:theme-next/hexo-next-utteranc#f592272a73cb47923f25443709786942f0398a69)
+-- hexo-related-popular-posts@4.0.0
+-- hexo-renderer-ejs@1.0.0
+-- hexo-renderer-marked@2.0.0
+-- hexo-renderer-stylus@1.1.0
+-- hexo-server@1.0.0
+-- hexo-symbols-count-time@0.7.1
+-- hexo-util@2.1.0
+-- pangu@4.0.7
+-- quicklink@2.0.0
+-- UNMET PEER DEPENDENCY react@^16.8.0
+-- UNMET PEER DEPENDENCY react-dom@^16.8.0
`-- shelljs@0.8.4

没有安装任何影响排序的插件,或是更改过这类机制的模板,比如:置顶文章。

@pplmx
Copy link
Author

pplmx commented Jun 3, 2020

@aixiu 可以发一下你的截图么,Thanks♪(・ω・)ノ

@aixiu
Copy link

aixiu commented Jun 4, 2020

@mystic-cg 配置上边已经有了,就发两张实际效果。
image 相关配置
image 实际效果,看看文章发表时间排序。
image
这是md文档修改时间

@pplmx
Copy link
Author

pplmx commented Jun 4, 2020

@aixiu
你理解错我的意思了, 我想要的是有更新日期, 而不是以更新日期排序显示.
因为可以通过自己添加代码,实现"发表于" 和 "更新于"这种功能
所以, 我想主题是否应该直接集成这个功能呢

@aixiu
Copy link

aixiu commented Jun 4, 2020

@mystic-cg
image
效果:如果有更新则显示更新时间,没有则不显示,配置文件见主题config.yml
主题已经自带了。。
next _config.yml

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

主要是 updated_at: 启用 enable: true。另:如果 another_day: flase 则没更新,也显示更新日期和发表日期为同一天。默认是开启的,没更新则不显示。

@pplmx
Copy link
Author

pplmx commented Jun 4, 2020

@aixiu 我的一直没生效

@aixiu
Copy link

aixiu commented Jun 4, 2020

@mystic-cg https://theme-next.js.org/docs/theme-settings/posts 这里的文档也有 Post Meta Display
image

@pplmx
Copy link
Author

pplmx commented Jun 4, 2020

我这些都做过,但是一直没生效
我的这个地址,我最近肯定有更新的,但是就是没显示
https://blog.caoyu.info/design-pattern.html

不确定是否因为,我将主题选择为英文模式有关?

@aixiu
Copy link

aixiu commented Jun 4, 2020

还不能确定,我所使用的插件,上边已经发了,还有主题使用也是和你一个版本,你本地测试中文模式试试。我很确定主题已经自带了你需要的功能。我没试过英文模式,所以不敢确定是不是BUG

@pplmx
Copy link
Author

pplmx commented Jun 4, 2020

@aixiu
image
可以工作

theme和hexo之间的配置应该有冲突了 @stevenjoezhang
image
将这个设置为false, 就可以了

@aixiu
Copy link

aixiu commented Jun 4, 2020

@mystic-cg 可能,我这个默认是未开启的。。恭喜你,解决问题。

@stevenjoezhang
Copy link
Member

stevenjoezhang commented Jun 4, 2020

问题解决了就好。use_date_for_updated 的默认值就是 false。设置为 true 时会导致更新日期不显示。
这个选项可能会在 Hexo 5 中被修改, 请注意有关动态: hexojs/hexo#4278
updated_option 特性目前不可用,将会在未来被 Hexo 支持。

如果更新到 Hexo 5,需要注意在 Hexo _config.yml 中使用

updated_option: 'mtime'

代替

use_date_for_updated: false

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Discussion Hexo Solved
Projects
No open projects
Hexo 5.0
  
In Progress
Development

No branches or pull requests

3 participants