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

index_generator失效问题 #4311

Closed
bamboo3333 opened this issue May 14, 2020 · 8 comments
Closed

index_generator失效问题 #4311

bamboo3333 opened this issue May 14, 2020 · 8 comments
Labels
question Needs help in usage

Comments

@bamboo3333
Copy link

新版本Hexo中配置文件配置主页面分页功能
index_generator:
path: ''
per_page: 8
order_by: -date
关键字index_generator:失效,新版本中如何设置主页分页功能?

@stevenjoezhang
Copy link
Member

经测试 index_generator 关键字有效。请提供更多信息。

@bamboo3333
Copy link
Author

刚刚重新试了一下,确实可以了,之前可能是我的配置问题,加载的时候一直报这个关键字load失败,谢谢了!

@stevenjoezhang
Copy link
Member

问题解决了就好。可能是之前格式有问题。

@stevenjoezhang stevenjoezhang added the question Needs help in usage label May 14, 2020
@cugxuan
Copy link

cugxuan commented Aug 10, 2020

@stevenjoezhang 抱歉打扰一下
hexo 最新版 5.0.2,next 7.7.2
order_by 字段好像不生效了

@stevenjoezhang
Copy link
Member

如果最近更新了 hexo-generator-index (3.0.0 版本),那么新的排序方式是

  1. 根据 order_by 排序
  2. 根据文章 Front Matter 中设定的 sticky 排序

第二步是一个稳定的排序算法,因此如果文章都没有设定 sticky,那么会保留第一步中排的顺序

@cugxuan
Copy link

cugxuan commented Aug 12, 2020

如果最近更新了 hexo-generator-index (3.0.0 版本),那么新的排序方式是

  1. 根据 order_by 排序
  2. 根据文章 Front Matter 中设定的 sticky 排序

第二步是一个稳定的排序算法,因此如果文章都没有设定 sticky,那么会保留第一步中排的顺序

您好,https://github.com/hexojs/hexo-generator-index/releases 我只看到有 2.0 的版本
官网文档里面写的

index_generator.order_by | Posts order. Order by descending date (new to old) by default. | -date

updated_option controls the updated value when not provided in the front-matter:
mtime: Use file modification date as updated. It is the default behavior of Hexo since 3.0.0

这个 3.0 我当时还以为是 hexo 的 3.0,而不是 hexo-generator-index

现在的问题:我不管设不设置 order_by 字段,顺序都不能以更新时间排序,最先显示最近修改的文件

# 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: 8
  order_by: -date

# 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
## Use post's date for updated date unless set in front-matter
updated_option: 'mtime'

package 版本

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "5.0.2"
  },
  "dependencies": {
    "hexo": "^5.0.2",
    "hexo-deployer-git": "^2.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-feed": "^2.2.0",
    "hexo-generator-index": "^2.0.0",
    "hexo-generator-search": "^2.4.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^3.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-server": "^1.0.0"
  }
}

@stevenjoezhang
Copy link
Member

您好,是 hexo-generator-index 的 2.0 版本,我之前写错了。
在 Hexo 的 _config.yml 中设置成这样试试

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

如果还不行的话,可能是由于 Hexo 没有正确读取文章的更新时间而造成的。这一问题可能在使用 Git 管理文章源码时出现: #3235

@cugxuan
Copy link

cugxuan commented Aug 12, 2020

您好,是 hexo-generator-index 的 2.0 版本,我之前写错了。
在 Hexo 的 _config.yml 中设置成这样试试

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

如果还不行的话,可能是由于 Hexo 没有正确读取文章的更新时间而造成的。这一问题可能在使用 Git 管理文章源码时出现: #3235

感觉有点奇怪,我尝试了 -update 以及和之前的几乎所有的组合,updated_option: 'date' 也尝试过了,还是不行,要么按照文章创建的顺序,从新到旧,要么会乱序、

我确实是使用 git 管理源码的,但是在 3235 中我似乎没有找到非常有用的信息,我有点不太懂,上面显示的更新时间都是正确的,只是排序的结果不对,这跟 git 有关系吗。

我用 hexo init 创建新的项目,使用默认的配置却是正常的,新项目中默认的配置是一样的,order_by: -updateupdated_option: 'mtime'

我还是没有找到啥地方有问题,先回退到 hexo 4.2.0 了,这个版本使用正常,打扰您了、

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Needs help in usage
Projects
None yet
Development

No branches or pull requests

3 participants