Reading info
提供关于页面内容的一些信息
配置参数
- name string
The key name to store the reading info value and the filter
Default:"readingInfo"
- extensions string[]
The list extensions this plugin applies to
Default:[ ".md" ]
- wordsPerMinute number
The words per minute a reader can read (default: 275)
Default:275
描述
这个插件在你的页面中创建一个名为 readingInfo
的变量,其中包含一些关于页面内容的有趣信息,例如阅读时间或页数。
安装
为了使用它,请在你的 _config.ts
文件中导入这个插件:
import lume from "lume/mod.ts";
import readingInfo from "lume/plugins/reading_info.ts";
const site = lume();
site.use(readingInfo());
export default site;
用法
它使用 Intl.Segmenter
标准函数来计数单词,并使用页面变量 lang
来检测语言。数据存储在变量 readingInfo
中,因此你可以在你的模板中这样使用它:
<p>{{ readingInfo.words }} words</p>
<p>{{ readingInfo.minutes }} min read</p>