我想转换以下Jekyll“阅读时间”计算器
<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.facebook}} 加 {{page.instagram}} 乘 {{page.age}} 划分 100万 将{{内容| number_of_words}} 划分 100 =
答案 0 :(得分:1)
这可以解决问题:
{% 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视为单词。Float