all repos — website @ 4df500c33f3d3ba7b9387a2bc0447850a04d15c8

My website

Make date format configurable
Alan Pearce alan@alanpearce.eu
Tue, 18 Apr 2023 09:29:56 +0200
commit

4df500c33f3d3ba7b9387a2bc0447850a04d15c8

parent

98d10546684524418a7f612cc75085b5ddc5cfaa

M config.tomlconfig.toml
@@ -19,6 +19,7 @@ # Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola highlight_code = true
 
 [extra]
+date_format="%d %b, %Y"
 
 [[extra.main_menu]]
 name = "Bear"
M templates/page.htmltemplates/page.html
@@ -11,7 +11,7 @@ {%- if page.date %} <p>
   <i>
     <time datetime='{{ page.date | date(format='%+') }}' pubdate>
-      {{ page.date | date(format="%d %b, %Y") }}
+      {{ page.date | date(format=config.extra.date_format) }}
     </time>
   </i>
 </p>
M templates/section.htmltemplates/section.html
@@ -14,7 +14,7 @@ <li>       <span>
         <i>
           <time datetime='{{ page.date | date(format='%+') }}' pubdate>
-            {{ page.date | date(format="%d %b, %Y") }}
+            {{ page.date | date(format=config.extra.date_format) }}
           </time>
         </i>
       </span>
M templates/taxonomy_single.htmltemplates/taxonomy_single.html
@@ -14,7 +14,7 @@ <li>       <span>
         <i>
           <time datetime='{{ page.date | date(format='%+') }}' pubdate>
-            {{ page.date | date(format="%d %b, %Y") }}
+            {{ page.date | date(format=config.extra.date_format) }}
           </time>
         </i>
       </span>
M theme.tomltheme.toml
@@ -12,6 +12,7 @@ # You don't need to prefix variables by the theme name but as this will # be merged with user data, some kind of prefix or nesting is preferable
 # Use snake_casing to be consistent with the rest of Zola
 [extra]
+date_format="%d %b, %Y"
 
 [author]
 name = "Alan Pearce"