From b58225a0128bd668873c399564926f81cf3e9610 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Thu, 31 Aug 2023 12:37:09 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(meta):=20allow=20hiding=20the?= =?UTF-8?q?=20read=20time=20indication=20on=20pages=20(#124)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: welpo --- config.toml | 4 ++++ templates/macros/content.html | 7 +++++-- theme.toml | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config.toml b/config.toml index d1885fe..a1ff959 100644 --- a/config.toml +++ b/config.toml @@ -185,6 +185,10 @@ stylesheets = [] # Add a "copy" button to codeblocks (loads ~700 bytes of JavaScript). copy_button = true +# Show the reading time of a page. +# Can also be enabled or disabled on individual pages in the front matter's [extra]. +show_reading_time = true + # Adds backlinks to footnotes (loads ~500 bytes of JavaScripts). footnote_backlinks = false diff --git a/templates/macros/content.html b/templates/macros/content.html index 9a45f5b..c8d5b80 100644 --- a/templates/macros/content.html +++ b/templates/macros/content.html @@ -22,10 +22,13 @@ {% endif %} {% if page.date %} -
  • {{ macros_format_date::format_date(date=page.date, short=true) }} {{ separator }}
  • +
  • {{ macros_format_date::format_date(date=page.date, short=true) }}
  • {% endif %} -
  •  {{ page.reading_time }}{%- if lang != config.default_language %} {{ trans(key="min_read" | safe, lang=lang) }} {% else %} min read {% endif %}
  • + {# page settings override config settings #} + {% if page.extra.show_reading_time | default(value="") == true or page.extra.show_reading_time | default(value="") != false and config.extra.show_reading_time | default(value=true) %} + {{ separator }}
  • {{ page.reading_time }}{%- if lang != config.default_language %} {{ trans(key="min_read" | safe, lang=lang) }} {% else %} min read {% endif %}
  • + {% endif %} {% if page.taxonomies and page.taxonomies.tags %}
  •  {{ separator }} {%- if lang != config.default_language -%}{{ trans(key="tags" | safe, lang=lang) | capitalize }}{% else %}Tags{%- endif -%}: 
  • diff --git a/theme.toml b/theme.toml index 61d70aa..cf7832c 100644 --- a/theme.toml +++ b/theme.toml @@ -70,6 +70,10 @@ stylesheets = [] # Add a "copy" button to codeblocks (loads ~700 bytes of JavaScript). copy_button = true +# Show the reading time of a page. +# Can also be enabled or disabled on individual pages in the front matter's [extra]. +show_reading_time = true + # Adds backlinks to footnotes (loads ~500 bytes of JavaScripts). footnote_backlinks = false