rspress-plugin-reading-time 0.2.0 → 1.0.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.
@@ -0,0 +1,14 @@
1
+ .rp-reading-time {
2
+ position: relative;
3
+ top: -18px;
4
+ font-style: italic;
5
+ font-size: 15px;
6
+ }
7
+
8
+ .rp-reading-time[data-dark='true'] {
9
+ color: rgba(235, 235, 235, 0.56);
10
+ }
11
+
12
+ .rp-reading-time[data-dark='false'] {
13
+ color: rgba(60, 60, 60, 0.66);
14
+ }
@@ -1,10 +1,10 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { usePageData, useLang, useDark } from 'rspress/runtime';
2
+ import { usePageData, useLang, useDark } from '@rspress/core/runtime';
3
3
 
4
4
  import type { ReadTimeResults } from 'reading-time';
5
5
  import type { PresetLocale, WithDefaultLocale } from 'rspress-plugin-devkit';
6
6
 
7
- import './ReadingTime.less';
7
+ import './ReadingTime.css';
8
8
 
9
9
  interface RspressReadingTimeComponentProps extends WithDefaultLocale {}
10
10
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type ReadTimeResults } from 'reading-time';
2
2
  import { type WithDefaultLocale } from 'rspress-plugin-devkit';
3
- import type { RspressPlugin } from '@rspress/shared';
3
+ import type { RspressPlugin } from '@rspress/core';
4
4
  export interface RspressPluginReadingTimeOptions extends WithDefaultLocale {
5
5
  getReadingTime?: (content: string) => ReadTimeResults;
6
6
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,+BAAgC,SAAQ,iBAAiB;IACxE,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,eAAe,CAAC;CACvD;AAED,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,OAAO,GAAE,+BAAoC,GAC5C,aAAa,CA6Bf"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import readingTime from 'reading-time';
3
- import { PresetConfigMutator, RemarkInsertComponentPluginFactory, } from 'rspress-plugin-devkit';
3
+ import { RemarkInsertComponentPluginFactory, } from 'rspress-plugin-devkit';
4
4
  export default function rspressPluginReadingTime(options = {}) {
5
5
  const { getReadingTime = readingTime, defaultLocale } = options;
6
6
  const remarkInsertReadingTime = new RemarkInsertComponentPluginFactory({
@@ -16,11 +16,10 @@ export default function rspressPluginReadingTime(options = {}) {
16
16
  });
17
17
  return {
18
18
  name: 'rspress-plugin-reading-time',
19
- config(config) {
20
- return new PresetConfigMutator(config).disableMdxRs().toConfig();
21
- },
19
+ // config not needed for Rspress V2
22
20
  extendPageData(pageData, isProd) {
23
21
  const estimatedReadingTime = getReadingTime(pageData.content);
22
+ // @ts-ignore - custom property
24
23
  pageData.readingTimeData = estimatedReadingTime;
25
24
  },
26
25
  markdown: {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "rspress-plugin-reading-time",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
+ "type": "module",
4
5
  "files": [
5
6
  "dist",
6
7
  "components"
@@ -27,9 +28,8 @@
27
28
  "access": "public"
28
29
  },
29
30
  "dependencies": {
30
- "@rspress/shared": "^1.17.1",
31
31
  "reading-time": "^1.5.0",
32
- "rspress-plugin-devkit": "^0.2.0"
32
+ "rspress-plugin-devkit": "^1.0.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^20.12.5",
@@ -37,7 +37,7 @@
37
37
  "typescript": "^5.4.4"
38
38
  },
39
39
  "peerDependencies": {
40
- "rspress": "*"
40
+ "@rspress/core": "^2.0.0-rc.4 || ^2.0.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsc --declarationMap false",
@@ -1,19 +0,0 @@
1
- @rp-reading-time: ~'rp-reading-time';
2
-
3
- @rp-reading-time-color-light: ~'rgba(60, 60, 60, 0.66)';
4
- @rp-reading-time-color-dark: ~'rgba(235, 235, 235, 0.56)';
5
-
6
- .@{rp-reading-time} {
7
- position: relative;
8
- top: -18px;
9
- font-style: italic;
10
- font-size: 15px;
11
-
12
- &[data-dark='true'] {
13
- color: @rp-reading-time-color-dark;
14
- }
15
-
16
- &[data-dark='false'] {
17
- color: @rp-reading-time-color-light;
18
- }
19
- }