feat(meta): allow overriding reading time setting from post

Also hides the separator if reading time is not shown.
This commit is contained in:
welpo 2023-08-31 16:37:23 +02:00
parent 497fe9d127
commit eeab0a03dd
No known key found for this signature in database
GPG key ID: A2F978CF4EC1F5A6
3 changed files with 9 additions and 3 deletions

View file

@ -186,6 +186,7 @@ stylesheets = []
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).

View file

@ -14,11 +14,12 @@
{% endif %}
{% if page.date %}
<li>{{ macros_format_date::format_date(date=page.date, short=true) }} {{ separator }}</li>
<li>{{ macros_format_date::format_date(date=page.date, short=true) }}</li>
{% endif %}
{% if page.extra.show_reading_time %}
<li title="{{ page.word_count }} {%- if lang != config.default_language %} {{ trans(key="words" | safe, lang=lang) }} {% else %} words {% endif %}">&nbsp;{{ page.reading_time }}{%- if lang != config.default_language %} {{ trans(key="min_read" | safe, lang=lang) }} {% else %} min read {% endif %}</li>
{# 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 }} <li title="{{ page.word_count }} {%- if lang != config.default_language %} {{ trans(key="words" | safe, lang=lang) }} {% else %} words {% endif %}">{{ page.reading_time }}{%- if lang != config.default_language %} {{ trans(key="min_read" | safe, lang=lang) }} {% else %} min read {% endif %}</li>
{% endif %}
{% if page.taxonomies and page.taxonomies.tags %}

View file

@ -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