Open ooooo-youwillsee opened 8 months ago
我尝试了下面的修改,可以达到我想要的效果
新建 layouts/partials/function/page.html
来处理分页逻辑
{{- $pages := .Pages -}}
{{- if eq .Site.Params.list.orderBy "title" -}}
{{- $pages = .Pages.ByTitle -}}
{{- else if eq .Site.Params.list.orderBy "weight" -}}
{{- $pages = .Pages.ByWeight -}}
{{- else -}}
{{- $pages = .Pages.GroupByDate "2006" -}}
{{- end -}}
{{- with .Site.Params.list.paginate | default .Site.Params.paginate -}}
{{- $pages = $.Paginate $pages . -}}
{{- end -}}
{{- return $pages -}}
修改 layouts/taxonomy/list.html
的分页展示逻辑
{{- /* Paginate */ -}}
{{- if .Pages -}}
{{- $pages := partial "function/page.html" . -}}
{{- if eq .Site.Params.list.orderBy "" -}}
{{- /* page group start */ -}}
{{- range $pages.PageGroups -}}
<h2 class="group-title">
{{- dict "Class" "fa-regular fa-calendar fa-fw me-1" | partial "plugin/icon.html" -}}
{{- .Key -}}
</h2>
{{- range .Pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- $repost := .Params.repost | default dict -}}
{{- if eq $repost.enable true -}}
{{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}}
{{- end -}}
{{- .LinkTitle -}}
</a>
<span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Date.Format }}'>
{{- .Date | dateFormat ($.Site.Params.list.dateFormat | default "01-02") -}}
</span>
</article>
{{- end -}}
{{- end -}}
{{- /* page group end */ -}}
{{- else -}}
{{- /* page start */ -}}
{{- range $pages.Pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- $repost := .Params.repost | default dict -}}
{{- if eq $repost.enable true -}}
{{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}}
{{- end -}}
{{- .LinkTitle -}}
</a>
<span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Date.Format }}'>
{{- .Date | dateFormat ($.Site.Params.list.dateFormat | default "01-02") -}}
</span>
</article>
{{- end -}}
{{- /* page end */ -}}
{{- end -}}
{{- partial "paginator.html" . -}}
{{- end -}}
新增配置
[params.list]
// order of pages, options values is ["title", "weight"], default value is "groupByDate" if empty
orderBy = "title"
我发现 tags
和 collections
,都是共用同一个 list.html
文件,这个有啥办法解决吗?
Describe the feature you want 描述你的功能需求
我写文章的命名方式
01 xxx 02 xxx 03 xxx
... 10 xxx
目前这些文件都是按照时间来排序的,从一开始写文档,我就会按照01,02把内容都划分好了,按照填空式写文章,并不是从01 依次写到 10,这样导致我每次都要调整时间
Useful reference 有价值的参考
No response