diff --git a/config.toml b/config.toml index 3397940..7d6f480 100644 --- a/config.toml +++ b/config.toml @@ -17,7 +17,7 @@ highlight_theme = "css" [extra] use_cdn = false -timeformat = "%d %B %Y" # Default format: "31 January 2049" +date_format = "" # If unset, uses format: "1st January 2049" #Full path after the base URL required. So if you were to place it in "static" it would be "/favicon.ico" favicon = "" diff --git a/templates/macros/macros.html b/templates/macros/macros.html index f20d227..19d86cf 100644 --- a/templates/macros/macros.html +++ b/templates/macros/macros.html @@ -1,3 +1,27 @@ +{% macro format_date(date) %} + {% if config.extra.date_format %} + {{ date | date(format=config.extra.date_format) }} + {% else %} + {% set day = date | date(format='%-d') | int %} + {% set suffix = "" %} + {% if day in [11, 12, 13] %} + {% set suffix = "th" %} + {% else %} + {% set last_digit = day % 10 %} + {% if last_digit == 1 %} + {% set suffix = "st" %} + {% elif last_digit == 2 %} + {% set suffix = "nd" %} + {% elif last_digit == 3 %} + {% set suffix = "rd" %} + {% else %} + {% set suffix = "th" %} + {% endif %} + {% endif %} + {{ date | date(format="%-d") }}{{ suffix }} {{ date | date(format="%B %Y") }} + {% endif %} +{% endmacro %} + {% macro list_posts(pages) %}