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

feat: add recently updated section #272

Merged
merged 4 commits into from
Oct 10, 2021
Merged

feat: add recently updated section #272

merged 4 commits into from
Oct 10, 2021

Conversation

HEIGE-PCloud
Copy link
Owner

@HEIGE-PCloud HEIGE-PCloud commented Oct 9, 2021

  • Add setting options in config.toml
  • Add translation for en and zh-CN
  • Only display posts modified within days days
  • Display maxCount posts at max
  • Only display "updated" posts with different .Lastmod and .Date
  • Add RSS support
  • Update documentation and sample config.toml

@HEIGE-PCloud HEIGE-PCloud added the enhancement Enhance existing features label Oct 9, 2021
@HEIGE-PCloud HEIGE-PCloud added this to the v0.2.13 milestone Oct 9, 2021
@HEIGE-PCloud HEIGE-PCloud self-assigned this Oct 9, 2021
@HEIGE-PCloud HEIGE-PCloud added this to In progress in Roadmap via automation Oct 9, 2021
@vercel
Copy link

vercel bot commented Oct 9, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pcloud/do-it/8g1ivDZkKi6msJHU4uMbWADDSQuP
✅ Preview: https://do-it-git-dev-lastmod-pcloud.vercel.app

@HEIGE-PCloud
Copy link
Owner Author

@gclm 麻烦帮忙测试一下,感谢!

@gclm
Copy link
Contributor

gclm commented Oct 10, 2021

@HEIGE-PCloud
目前经测试有以下问题:

  1. 时间建议是全时间如:2021-09-22,目前是09-22

image
2. 边界bug,目前时间是:2021-10-10,如果我把文章更新时间调整到未来,如:2021-11-22

最新更新应该是基于当前时间来算的。

image
image

@HEIGE-PCloud
Copy link
Owner Author

HEIGE-PCloud commented Oct 10, 2021

时间应该是全时间如:2021-09-22,目前是09-22

这个时间格式是与下方的时间格式保持一致的,你可以通过配置 config.toml[params.section] 下的 dateFormat 选项来修改它的格式。

边界bug

“更新时间”是基于 lastmod 参数的数值计算的,因为主题本身并没有能力判断你是否“修改”或者“更新”了哪一篇文章。正确的使用方式是正确配置 gitRepo 参数,并且开启 enableGitInfo 选项,让 Hugo 使用 git 中的信息自动更新 .Lastmod。当 git 信息没有配置时,.Lastmod 会使用 front matter 中 lastmod 参数的数值。如果你(出于任何原因)将其配置为一个未来的时间,那么它就应该显示一个未来的时间。

@HEIGE-PCloud
Copy link
Owner Author

image

倒确实有一个边界问题,当没有文章符合要求时,不应该显示标题。

@gclm
Copy link
Contributor

gclm commented Oct 10, 2021

时间应该是全时间如:2021-09-22,目前是09-22

这个时间格式是与下方的时间格式保持一致的,你可以通过配置 config.toml[params.section] 下的 dateFormat 选项来修改它的格式。

如果我只想让最近更新的显示时间为全格式如何处理呢?

目前这个主题支持这样操作不,如果子选项配置了用子选项的如果子选项没配置的话用复选项的
image

@HEIGE-PCloud
Copy link
Owner Author

时间应该是全时间如:2021-09-22,目前是09-22

这个时间格式是与下方的时间格式保持一致的,你可以通过配置 config.toml[params.section] 下的 dateFormat 选项来修改它的格式。

如果我只想让最近更新的显示时间为全格式如何处理呢?

那你可以把 recentlyUpdated.html 中的

{{- $.Site.Params.section.dateFormat | default "01-02" | .Lastmod.Format -}}

换成

{{- "2006-01-02" | .Lastmod.Format -}}

@HEIGE-PCloud HEIGE-PCloud merged commit 4c4ffff into main Oct 10, 2021
Roadmap automation moved this from In progress to Done Oct 10, 2021
@HEIGE-PCloud HEIGE-PCloud deleted the dev/lastmod branch October 10, 2021 12:00
@HEIGE-PCloud
Copy link
Owner Author

HEIGE-PCloud commented Oct 10, 2021

大多数情况下,最近更新的文章总是有最新的年份,所以这个年份显示是多余的,且造成显示格式的不一致。

image

如果你(出于任何原因)将 days 配置为了一个很大的天数(虽然并不应该这么做),或者在年初时(比如一月份),确实会有不同年份的文章同时出现。但是该列表本身是按照新旧顺序排序的,出现“一月份在十二月份”上方也并不会造成什么困惑。

@gclm
Copy link
Contributor

gclm commented Oct 10, 2021

我明白你的意思了。但是我对这块代码的建议是增加一个参数dateFormat
recentlyUpdated.html 中的

{{- $.Site.Params.section.dateFormat | default "01-02" | .Lastmod.Format -}}

修改成:

{{- $.Site.Params.section.recentlyUpdated.dateFormat | default "01-02" | .Lastmod.Format -}}

让使用者去自己自定义,这块如何处理。

@HEIGE-PCloud HEIGE-PCloud added new feature New feature and removed enhancement Enhance existing features labels Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature
Projects
No open projects
Roadmap
  
Done
Development

Successfully merging this pull request may close these issues.

[FEATURE] 新增最近10篇文章(已经实现不会搞多语言)
2 participants