将 Jekyll "reading time" 转换为 "page rating calculation"
Transform Jekyll "reading time" into "page rating calculation"
我想改造跟随 Jekyll "reading time" 计算器
<span class="reading-time">
{% capture words %}
{{ content | number_of_words | minus: 180 }}
{% endcapture %}
{% unless words contains “-” %}
{{ words | plus: 180 | divided_by: 180 |
append: “minutes to read” }}
{% endunless %}
</span>
进入 "page rating",使用以下公式
从页面 Front matter 获取以下元数据
{{ page.facebook }}
加
{{ page.instagram }}
乘
{{ page.age }}
划分
1000 000
乘以{{内容| number_of_words}}
划分
100 =
这可以解决问题:
{% assign number_of_words = content | strip_html | number_of_words %}
{% assign social = page.facebook | plus: page.instagram %}
{% comment %}Two lines for readability, but can be chained on one line{% endcomment %}
{% assign Indexmod = social | times: page.age | divided_by: 1000000.0 %}
{% assign Indexmod = Indexmod | times: number_of_words | divided_by: 100 %}
注:
- 使用
strip_html
,避免将html算作单词。
- 使用 'divided_by: 1000000.0' 将结果转换为
Float
我想改造跟随 Jekyll "reading time" 计算器
<span class="reading-time">
{% capture words %}
{{ content | number_of_words | minus: 180 }}
{% endcapture %}
{% unless words contains “-” %}
{{ words | plus: 180 | divided_by: 180 |
append: “minutes to read” }}
{% endunless %}
</span>
进入 "page rating",使用以下公式
从页面 Front matter 获取以下元数据{{ page.facebook }} 加 {{ page.instagram }} 乘 {{ page.age }} 划分 1000 000 乘以{{内容| number_of_words}} 划分 100 =
这可以解决问题:
{% assign number_of_words = content | strip_html | number_of_words %}
{% assign social = page.facebook | plus: page.instagram %}
{% comment %}Two lines for readability, but can be chained on one line{% endcomment %}
{% assign Indexmod = social | times: page.age | divided_by: 1000000.0 %}
{% assign Indexmod = Indexmod | times: number_of_words | divided_by: 100 %}
注:
- 使用
strip_html
,避免将html算作单词。 - 使用 'divided_by: 1000000.0' 将结果转换为
Float