Explorar o código

Add lastmod to post

zwbetz %!s(int64=6) %!d(string=hai) anos
pai
achega
90caaa368c
Modificáronse 3 ficheiros con 14 adicións e 1 borrados
  1. 1 0
      exampleSite/config.toml
  2. 1 0
      exampleSite/config.yaml
  3. 12 1
      layouts/post/single.html

+ 1 - 0
exampleSite/config.toml

@@ -5,6 +5,7 @@ title = "Cupper"
 theme = "cupper-hugo-theme"
 googleAnalytics = "UA-123456789-1"
 disqusShortname = "yourdiscussshortname"
+enableGitInfo = true
 
 [taxonomies]
   tag = "tags"

+ 1 - 0
exampleSite/config.yaml

@@ -5,6 +5,7 @@ title: Cupper
 theme: cupper-hugo-theme
 googleAnalytics: UA-123456789-1
 disqusShortname: yourdiscussshortname
+enableGitInfo: true
 
 taxonomies:
   tag: tags

+ 12 - 1
layouts/post/single.html

@@ -6,10 +6,19 @@
       </svg>
       {{ .Title }}
     </h1>
+
     <div class="date">
       {{ $dateFormat := $.Site.Params.dateFormat | default "Jan 2, 2006" }}
-      <strong aria-hidden="true">Publish date: </strong>{{ .PublishDate.Format $dateFormat }}
+      {{ $publishDate := .PublishDate }}
+      <strong aria-hidden="true">Publish date: </strong>{{ $publishDate.Format $dateFormat }}
+      {{ with .Lastmod }}
+        {{ if gt . $publishDate }}
+          <br>
+          <strong aria-hidden="true">Last mod date: </strong>{{ .Format $dateFormat }}
+        {{ end }}
+      {{ end }}
     </div>
+
     {{ with .Params.tags }}
       <div class="tags">
         <strong aria-hidden="true">Tags: </strong>
@@ -26,9 +35,11 @@
         </ul>
       </div>
     {{ end }}
+    
     {{ if ne .Params.toc false }}
       {{ partial "toc" . }}
     {{ end }}
+
     {{ .Content }}
   </main>
   {{ partial "disqus.html" . }}