From 1cb25b912b96158e4afc321311105b8681fbd5c0 Mon Sep 17 00:00:00 2001 From: Misty Stanley-Jones Date: Wed, 9 Nov 2016 11:53:08 -0800 Subject: [PATCH] Implement per-page reading-time stats Does not rely on Jekyll plugin but uses pure Liquid Included basic CSS Signed-off-by: Misty Stanley-Jones --- _includes/read_time.html | 9 +++++++++ _layouts/docs.html | 1 + css/documentation.css | 14 ++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 _includes/read_time.html diff --git a/_includes/read_time.html b/_includes/read_time.html new file mode 100644 index 0000000000..9a7565e233 --- /dev/null +++ b/_includes/read_time.html @@ -0,0 +1,9 @@ + + Estimated reading time: + {% assign words = content | number_of_words %} + {% if words < 360 %} + 1 minute + {% else %} + {{ words | divided_by:180 }} minutes + {% endif %} + diff --git a/_layouts/docs.html b/_layouts/docs.html index b48a045d07..1e02527f66 100644 --- a/_layouts/docs.html +++ b/_layouts/docs.html @@ -187,6 +187,7 @@ ng\:form {
{% if page.title %}

{{ page.title }}

{% endif %} {% if page.advisory %}

{{ site.data.advisories.texts[page.advisory] }}

{% endif %} + {% include read_time.html %} {{ content }} {% if page.noratings != true %}
diff --git a/css/documentation.css b/css/documentation.css index 304b9d18ce..45bca67bf5 100644 --- a/css/documentation.css +++ b/css/documentation.css @@ -346,3 +346,17 @@ color: #F04124; } /* end search */ + +/* begin reading_time */ + +span.reading-time { + font-style: italic; + font-size: 80%; + display: block; + padding-top: 10px; + padding-bottom: 10px; + color: #999; +} + +span.reading-time-label { +}