在我的模板中,我按月份對我的帖子進行排序,如下所示:{{ range (where site.RegularPages "Type" "in" site.Params.mainSections).GroupByDate "January, 2006" -}} <h1>{{ .Key }}</h1> // output: March, 2022 {{ range (where .Pages ".Params.unlisted" "!=" "true") }} <div>{{ time.Format "02 January" .Date }} - {{ .Title }}</div> // output: 01 Mars - This is the title of my post {{ end }}{{ end }}對于每個帖子,time.Format我的日期都用我的語言本地化了(這里是法語)。但是witch is group by month的標題還是英文的(這里是h1)。我如何格式化我的{{ .Key }}以便它可以本地化為我自己的語言并顯示“Mars, 2022”而不是“March, 2022”?
2 回答

慕斯709654
TA貢獻1840條經驗 獲得超5個贊
怎么樣:
{{ time.Format "02 January" .Key }}
還是我缺少什么?
更新:您可以像這樣按月份排序:
{{ range (where site.RegularPages "Type" "in" site.Params.mainSections).GroupByDate "1 2006" -}}
然后你可以用一個空格分開你的 .Key 并為你的本地化月份創建一個手動查找。不是很漂亮,但它完成了工作。
- 2 回答
- 0 關注
- 228 瀏覽
添加回答
舉報
0/150
提交
取消