rspress-plugin-reading-time 0.1.1 → 0.1.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README.zh-CN.md +52 -0
- package/package.json +2 -2
package/README.md
CHANGED
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# rspress-plugin-reading-time 
|
|
2
|
+
|
|
3
|
+
在你的文档页面中显示阅读时间的 Rspress 插件。
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## 使用
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i rspress-plugin-reading-time
|
|
11
|
+
pnpm add rspress-plugin-reading-time
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
import { defineConfig } from 'rspress/config';
|
|
17
|
+
import readingTime from 'rspress-plugin-reading-time';
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
root: path.join(__dirname, 'docs'),
|
|
21
|
+
plugins: [readingTime()],
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 配置
|
|
26
|
+
|
|
27
|
+
### getReadingTime
|
|
28
|
+
|
|
29
|
+
用于计算预估阅读时间的函数,默认使用 [reading-time](https://www.npmjs.com/package/reading-time) 包进行估算。
|
|
30
|
+
|
|
31
|
+
- Type: `(content: string) => ReadTimeResults`
|
|
32
|
+
|
|
33
|
+
### defaultLocale
|
|
34
|
+
|
|
35
|
+
在站点未设置 locales 时,用于阅读时间文本的默认语言,默认使用 `en-US`。
|
|
36
|
+
|
|
37
|
+
- Type: `string`
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import * as path from 'path';
|
|
41
|
+
import { defineConfig } from 'rspress/config';
|
|
42
|
+
import readingTime from 'rspress-plugin-reading-time';
|
|
43
|
+
|
|
44
|
+
export default defineConfig({
|
|
45
|
+
root: path.join(__dirname, 'docs'),
|
|
46
|
+
plugins: [
|
|
47
|
+
readingTime({
|
|
48
|
+
defaultLocale: 'zh-CN',
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rspress-plugin-reading-time",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-beta.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@rspress/shared": "^1.17.1",
|
|
30
30
|
"reading-time": "^1.5.0",
|
|
31
|
-
"rspress-plugin-devkit": "^0.1.
|
|
31
|
+
"rspress-plugin-devkit": "^0.1.3-beta.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^20.12.5",
|