Browse Source

Add `time_format` variable for customizing talk time (#353)

* Add `time_format` variable to `config.toml`
   * Enables customizing talk time between am/pm or 24h format
* Correct Go date format URL in documentation
Serge Bibauw 7 năm trước cách đây
mục cha
commit
45b2e054e7

+ 4 - 2
exampleSite/config.toml

@@ -69,9 +69,11 @@ defaultContentLanguageInSubdir = false
   latitude = "37.4275"
   latitude = "37.4275"
   longitude = "-122.1697"
   longitude = "-122.1697"
 
 
-  # Date format (refer to Go's date format: http://flippinggodateformat.com )
+  # Date and time format (refer to Go's date format: http://fuckinggodateformat.com )
   #   Examples: "Mon, Jan 2, 2006" or "2006-01-02"
   #   Examples: "Mon, Jan 2, 2006" or "2006-01-02"
   date_format = "Jan 2, 2006"
   date_format = "Jan 2, 2006"
+  #   Examples: "3:04 pm" or "15:04"
+  time_format = "3:04 PM"
 
 
   # Show estimated reading time for posts?
   # Show estimated reading time for posts?
   reading_time = true
   reading_time = true
@@ -143,7 +145,7 @@ defaultContentLanguageInSubdir = false
 
 
   # Configuration of publication pages.
   # Configuration of publication pages.
   [params.publications]
   [params.publications]
-    # Date format (refer to Go's date format: http://flippinggodateformat.com )
+    # Date format (refer to Go's date format: http://fuckinggodateformat.com )
     #   Examples: "Mon, Jan 2, 2006" or "2006-01-02"
     #   Examples: "Mon, Jan 2, 2006" or "2006-01-02"
     date_format = "January, 2006"
     date_format = "January, 2006"
 
 

+ 2 - 2
layouts/partials/talk_li_detailed.html

@@ -33,9 +33,9 @@
       <div class="talk-metadata" itemprop="startDate">
       <div class="talk-metadata" itemprop="startDate">
         {{ $date := .Params.time_start | default .Date }}
         {{ $date := .Params.time_start | default .Date }}
         {{ (time $date).Format $.Site.Params.date_format }}
         {{ (time $date).Format $.Site.Params.date_format }}
-        {{ (time $date).Format "3:04 PM" }}
+        {{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
         {{ with .Params.time_end }}
         {{ with .Params.time_end }}
-        &mdash; {{ (time .).Format "3:04 PM" }}
+        &mdash; {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
         {{ end }}
         {{ end }}
       </div>
       </div>
 
 

+ 1 - 1
layouts/partials/talk_li_simple.html

@@ -4,7 +4,7 @@
   <div itemprop="startDate">
   <div itemprop="startDate">
     {{ $date := .Params.time_start | default .Date }}
     {{ $date := .Params.time_start | default .Date }}
     {{ (time $date).Format $.Site.Params.date_format }}
     {{ (time $date).Format $.Site.Params.date_format }}
-    {{ (time $date).Format "3:04 PM" }}
+    {{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
   </div>
   </div>
   <div class="talk-metadata">
   <div class="talk-metadata">
     {{ if .Params.event_short }}
     {{ if .Params.event_short }}

+ 2 - 2
layouts/talk/single.html

@@ -34,9 +34,9 @@
             {{ $date := .Params.time_start | default .Date }}
             {{ $date := .Params.time_start | default .Date }}
             {{ (time $date).Format $.Site.Params.date_format }}
             {{ (time $date).Format $.Site.Params.date_format }}
             <div class="talk-time">
             <div class="talk-time">
-              {{ (time $date).Format "3:04 PM" }}
+              {{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
               {{ with .Params.time_end }}
               {{ with .Params.time_end }}
-              &mdash; {{ (time .).Format "3:04 PM" }}
+              &mdash; {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
               {{ end }}
               {{ end }}
             </div>
             </div>
           </div>
           </div>