Skip to content

Commit

Permalink
show last modified time
Browse files Browse the repository at this point in the history
  • Loading branch information
HidegonSan committed Aug 12, 2023
1 parent 2673811 commit f6d1340
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 7 additions & 2 deletions hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ disableHugoGeneratorInject: true
enableRobotsTXT: true
googleAnalytics: "G-13NX4L943B"

enableGitInfo: true

minify:
disableXML: true
minifyOutput: true
Expand All @@ -31,8 +33,11 @@ taxonomies:
tag: "tags"


frontMatter:
lastMod: ":fileModTime"
# Thanks: https://shunyaueta.com/posts/2021-10-06/
frontmatter:
lastmod:
- lastmod
- :git


params:
Expand Down
15 changes: 8 additions & 7 deletions layouts/partials/post_meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@

{{/* 公開日と更新日が違う場合、両方を表示 */}}
{{ if and (ne $lastmod $date) }}
<time itemprop="datePublished" datetime="{{ .Date }}">
公開: {{ .Date.Format "2006-01-02" }}</time>
<time itemprop="dateModified" datetime="{{ .Lastmod }}">
&nbsp;|&nbsp;更新: {{ .Lastmod.Format "2006-01-02" }}</time>
{{/* 公開日と更新日が同じ場合、公開日のみ表示 */}}
<time itemprop="datePublished" datetime="{{ .Date }}">公開: {{ .Date.Format "2006-01-02" }}</time>
{{- if not .Lastmod.IsZero -}}
<time itemprop="dateModified" datetime="{{ .Lastmod }}">&nbsp;|&nbsp;更新: {{ .Lastmod.Format "2006-01-02" }}</time>
{{ end }}
{{/* 公開日と更新日が同じ場合、公開日のみ表示 */}}
{{ else }}
<time itemprop="datePublished" datetime="{{ .Date }}">
公開: {{ .Date.Format "2006-01-02" }}</time>
{{- if not .Date.IsZero -}}
<time itemprop="datePublished" datetime="{{ .Date }}">公開: {{ .Date.Format "2006-01-02" }}</time>
{{ end }}
{{ end }}

0 comments on commit f6d1340

Please sign in to comment.