Ver código fonte

posts: Support `lastmod` param to show date last modified

George Cushen 8 anos atrás
pai
commit
97590cb12e

+ 1 - 1
exampleSite/config.toml

@@ -37,7 +37,7 @@ defaultContentLanguageInSubdir = false
 
   # Date format (refer to Go's date format: http://flippinggodateformat.com )
   #   Examples: "Mon, Jan 2, 2006" or "2006-01-02"
-  date_format = "Mon, Jan 2, 2006"
+  date_format = "Jan 2, 2006"
 
   # Enable global LaTeX math rendering?
   #   If false, you can enable it locally on a per page basis.

+ 1 - 1
exampleSite/content/post/_index.md

@@ -1,6 +1,6 @@
 +++
 title = "Posts"
-date = "2017-01-01T00:00:00Z"
+date = 2017-01-01
 math = false
 highlight = false
 

+ 2 - 1
exampleSite/content/post/getting-started.md

@@ -1,5 +1,6 @@
 +++
-date = "2016-04-20T12:00:00"
+date = 2016-04-20
+lastmod = 2017-09-03
 draft = false
 tags = ["academic", "hugo"]
 title = "Getting started with the Academic framework for Hugo"

+ 1 - 1
exampleSite/content/post/managing-content.md

@@ -1,5 +1,5 @@
 +++
-date = "2016-04-20T11:00:00"
+date = 2016-04-18
 draft = false
 tags = ["academic", "hugo"]
 title = "Managing content"

+ 1 - 1
exampleSite/content/post/migrate-from-jekyll.md

@@ -1,5 +1,5 @@
 +++
-date = "2014-03-10T00:00:00"
+date = 2014-03-10
 draft = false
 tags = ["jekyll"]
 title = "Migrate from Jekyll to Hugo"

+ 1 - 1
exampleSite/content/post/widgets.md

@@ -1,5 +1,5 @@
 +++
-date = "2016-04-20T11:00:00"
+date = 2016-04-19
 draft = false
 tags = ["academic", "hugo"]
 title = "Customizing the homepage with widgets"

+ 1 - 1
exampleSite/content/post/writing-markdown-latex.md

@@ -1,5 +1,5 @@
 +++
-date = "2016-04-20T10:00:00"
+date = 2016-04-17
 draft = false
 tags = []
 title = "Writing content with Markdown, LaTeX, and Shortcodes"

+ 3 - 0
i18n/en.yaml

@@ -66,6 +66,9 @@
 - id: date
   translation: Date
 
+- id: last_updated
+  translation: Last updated on
+
 - id: links
   translation: Links
 

+ 4 - 1
layouts/partials/article_metadata.html

@@ -3,8 +3,11 @@
 <div class="article-metadata">
 
   <span class="article-date">
+    {{ if ne $.Params.Lastmod $.Params.Date }}
+        {{ i18n "last_updated" }}
+    {{ end }}
     <time datetime="{{ $.Date }}" itemprop="datePublished">
-      {{ $.Date.Format $.Site.Params.date_format }}
+      {{ $.Lastmod.Format $.Site.Params.date_format }}
     </time>
   </span>