feat(lastUpdated): introduce last modified author using GitInfo (#857)
* feat(lastUpdated): introduce last modified author using GitInfo * feat: change by string for just • * docs: add documentation for displayUpdatedAuthor parameter Document the new displayUpdatedAuthor config option in all language versions (en, zh-cn, ja, fa). Also disable it by default in the example hugo.yaml. --------- Co-authored-by: Xin <5097752+imfing@users.noreply.github.com> Co-authored-by: Xin <xin@imfing.com>
This commit is contained in:
@@ -285,6 +285,8 @@ params:
|
|||||||
|
|
||||||
برای سفارشی کردن فرمت تاریخ، پارامتر `params.dateFormat` را تنظیم کنید. چیدمان آن با [`time.Format`](https://gohugo.io/functions/time/format/) Hugo مطابقت دارد.
|
برای سفارشی کردن فرمت تاریخ، پارامتر `params.dateFormat` را تنظیم کنید. چیدمان آن با [`time.Format`](https://gohugo.io/functions/time/format/) Hugo مطابقت دارد.
|
||||||
|
|
||||||
|
علاوه بر این، میتوانید با فعال کردن پرچم `params.displayUpdatedAuthor` نویسنده آخرین تغییر را نمایش دهید. این نیاز به تنظیم `enableGitInfo: true` دارد.
|
||||||
|
|
||||||
```yaml {filename="hugo.yaml"}
|
```yaml {filename="hugo.yaml"}
|
||||||
# تجزیه commit Git
|
# تجزیه commit Git
|
||||||
enableGitInfo: true
|
enableGitInfo: true
|
||||||
@@ -293,6 +295,8 @@ params:
|
|||||||
# نمایش تاریخ آخرین تغییر
|
# نمایش تاریخ آخرین تغییر
|
||||||
displayUpdatedDate: true
|
displayUpdatedDate: true
|
||||||
dateFormat: "January 2, 2006"
|
dateFormat: "January 2, 2006"
|
||||||
|
# نمایش نویسنده آخرین تغییر
|
||||||
|
displayUpdatedAuthor: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### برچسبها
|
### برچسبها
|
||||||
|
|||||||
@@ -285,6 +285,8 @@ params:
|
|||||||
|
|
||||||
日付形式をカスタマイズするには、`params.dateFormat` パラメータを設定します。そのレイアウトは Hugo の [`time.Format`](https://gohugo.io/functions/time/format/) に準拠します。
|
日付形式をカスタマイズするには、`params.dateFormat` パラメータを設定します。そのレイアウトは Hugo の [`time.Format`](https://gohugo.io/functions/time/format/) に準拠します。
|
||||||
|
|
||||||
|
さらに、`params.displayUpdatedAuthor` フラグを有効にすると、最終更新の作者を表示できます。これには `enableGitInfo: true` の設定が必要です。
|
||||||
|
|
||||||
```yaml {filename="hugo.yaml"}
|
```yaml {filename="hugo.yaml"}
|
||||||
# Git コミットを解析
|
# Git コミットを解析
|
||||||
enableGitInfo: true
|
enableGitInfo: true
|
||||||
@@ -293,6 +295,8 @@ params:
|
|||||||
# 最終更新日を表示
|
# 最終更新日を表示
|
||||||
displayUpdatedDate: true
|
displayUpdatedDate: true
|
||||||
dateFormat: "2006年1月2日"
|
dateFormat: "2006年1月2日"
|
||||||
|
# 最終更新の作者を表示
|
||||||
|
displayUpdatedAuthor: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### タグ
|
### タグ
|
||||||
|
|||||||
@@ -307,6 +307,8 @@ The date of the page's last modification can be displayed by enabling the `param
|
|||||||
|
|
||||||
To customize the date format, set the `params.dateFormat` parameter. Its layout matches Hugo's [`time.Format`](https://gohugo.io/functions/time/format/).
|
To customize the date format, set the `params.dateFormat` parameter. Its layout matches Hugo's [`time.Format`](https://gohugo.io/functions/time/format/).
|
||||||
|
|
||||||
|
Additionally, the author of the last modification can be displayed by enabling the `params.displayUpdatedAuthor` flag. This requires `enableGitInfo: true` to be set.
|
||||||
|
|
||||||
```yaml {filename="hugo.yaml"}
|
```yaml {filename="hugo.yaml"}
|
||||||
# Parse Git commit
|
# Parse Git commit
|
||||||
enableGitInfo: true
|
enableGitInfo: true
|
||||||
@@ -315,6 +317,8 @@ params:
|
|||||||
# Display the last modification date
|
# Display the last modification date
|
||||||
displayUpdatedDate: true
|
displayUpdatedDate: true
|
||||||
dateFormat: "January 2, 2006"
|
dateFormat: "January 2, 2006"
|
||||||
|
# Display the author of the last modification
|
||||||
|
displayUpdatedAuthor: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tags
|
### Tags
|
||||||
|
|||||||
@@ -285,6 +285,8 @@ params:
|
|||||||
|
|
||||||
要自定义日期格式,设置 `params.dateFormat` 参数。其布局与 Hugo 的 [`time.Format`](https://gohugo.io/functions/time/format/) 匹配。
|
要自定义日期格式,设置 `params.dateFormat` 参数。其布局与 Hugo 的 [`time.Format`](https://gohugo.io/functions/time/format/) 匹配。
|
||||||
|
|
||||||
|
此外,可以通过启用 `params.displayUpdatedAuthor` 标志来显示最后修改的作者。这需要设置 `enableGitInfo: true`。
|
||||||
|
|
||||||
```yaml {filename="hugo.yaml"}
|
```yaml {filename="hugo.yaml"}
|
||||||
# 解析 Git 提交
|
# 解析 Git 提交
|
||||||
enableGitInfo: true
|
enableGitInfo: true
|
||||||
@@ -293,6 +295,8 @@ params:
|
|||||||
# 显示最后修改日期
|
# 显示最后修改日期
|
||||||
displayUpdatedDate: true
|
displayUpdatedDate: true
|
||||||
dateFormat: "2006年1月2日"
|
dateFormat: "2006年1月2日"
|
||||||
|
# 显示最后修改的作者
|
||||||
|
displayUpdatedAuthor: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### 标签
|
### 标签
|
||||||
|
|||||||
@@ -194,6 +194,9 @@ params:
|
|||||||
displayUpdatedDate: true
|
displayUpdatedDate: true
|
||||||
dateFormat: "January 2, 2006"
|
dateFormat: "January 2, 2006"
|
||||||
|
|
||||||
|
# Display the author name of the last modified date
|
||||||
|
displayUpdatedAuthor: false
|
||||||
|
|
||||||
# Search
|
# Search
|
||||||
# flexsearch is enabled by default
|
# flexsearch is enabled by default
|
||||||
search:
|
search:
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
{{- $lastUpdated := (T "lastUpdated") | default "Last updated on" -}}
|
{{- $lastUpdated := (T "lastUpdated") | default "Last updated on" -}}
|
||||||
|
{{- $page := . -}}
|
||||||
|
|
||||||
{{- if site.Params.displayUpdatedDate -}}
|
{{- if site.Params.displayUpdatedDate -}}
|
||||||
{{- with .Lastmod -}}
|
{{- with .Lastmod -}}
|
||||||
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
|
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
|
||||||
<div class="hx:mt-12 hx:mb-8 hx:block hx:text-xs hx:text-gray-500 hx:ltr:text-right hx:rtl:text-left hx:dark:text-gray-400">{{ $lastUpdated }} <time datetime="{{ $datetime }}">{{ partial "utils/format-date" . }}</time></div>
|
<div class="hx:mt-12 hx:mb-8 hx:block hx:text-xs hx:text-gray-500 hx:ltr:text-right hx:rtl:text-left hx:dark:text-gray-400">
|
||||||
|
{{ $lastUpdated }} <time datetime="{{ $datetime }}">{{ partial "utils/format-date" . }}</time>
|
||||||
|
{{- if site.Params.displayUpdatedAuthor -}}
|
||||||
|
{{- with $page.GitInfo -}}
|
||||||
|
{{ print " • " .AuthorName | safeHTML }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
</div>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<div class="hx:mt-16"></div>
|
<div class="hx:mt-16"></div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user