@docusaurus/plugin-ideal-image 0.0.0-4728 → 0.0.0-4732
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.
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import ReactIdealImage from '@endiliey/react-ideal-image';
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
// Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/helpers.js#L59-L65
|
|
11
|
-
|
|
11
|
+
function bytesToSize(bytes) {
|
|
12
12
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
13
13
|
if (bytes === 0) {
|
|
14
14
|
return 'n/a';
|
|
@@ -18,9 +18,9 @@ const bytesToSize = (bytes) => {
|
|
|
18
18
|
return `${bytes} ${sizes[scale]}`;
|
|
19
19
|
}
|
|
20
20
|
return `${(bytes / 1024 ** scale).toFixed(1)} ${sizes[scale]}`;
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
// Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/IdealImage/index.js#L43-L75
|
|
23
|
-
|
|
23
|
+
function getMessage(icon, state) {
|
|
24
24
|
switch (icon) {
|
|
25
25
|
case 'noicon':
|
|
26
26
|
case 'loaded':
|
|
@@ -70,7 +70,7 @@ const getMessage = (icon, state) => {
|
|
|
70
70
|
default:
|
|
71
71
|
throw new Error(`Wrong icon: ${icon}`);
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|
|
74
74
|
export default function IdealImage(props) {
|
|
75
75
|
const {alt, className, img} = props;
|
|
76
76
|
// In dev env just use regular img with original file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-ideal-image",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4732",
|
|
4
4
|
"description": "Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder).",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-ideal-image.d.ts",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/lqip-loader": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4732",
|
|
25
|
+
"@docusaurus/lqip-loader": "0.0.0-4732",
|
|
26
26
|
"@docusaurus/responsive-loader": "^1.7.0",
|
|
27
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
28
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
27
|
+
"@docusaurus/theme-translations": "0.0.0-4732",
|
|
28
|
+
"@docusaurus/utils-validation": "0.0.0-4732",
|
|
29
29
|
"@endiliey/react-ideal-image": "^0.0.11",
|
|
30
30
|
"react-waypoint": "^10.1.0",
|
|
31
31
|
"sharp": "^0.30.3",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"webpack": "^5.70.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
37
|
-
"@docusaurus/types": "0.0.0-
|
|
36
|
+
"@docusaurus/module-type-aliases": "0.0.0-4732",
|
|
37
|
+
"@docusaurus/types": "0.0.0-4732",
|
|
38
38
|
"fs-extra": "^10.0.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=14"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "da1dfdadc386a446278acd3922f327b291b7b7f1"
|
|
54
54
|
}
|
|
@@ -14,8 +14,7 @@ declare module '@docusaurus/plugin-ideal-image' {
|
|
|
14
14
|
/**
|
|
15
15
|
* Specify all widths you want to use; if a specified size exceeds the
|
|
16
16
|
* original image's width, the latter will be used (i.e. images won't be
|
|
17
|
-
* scaled up).
|
|
18
|
-
* options in your webpack.config.js.
|
|
17
|
+
* scaled up).
|
|
19
18
|
*/
|
|
20
19
|
sizes?: number[];
|
|
21
20
|
/**
|
|
@@ -25,16 +24,17 @@ declare module '@docusaurus/plugin-ideal-image' {
|
|
|
25
24
|
*/
|
|
26
25
|
size?: number;
|
|
27
26
|
/**
|
|
28
|
-
* As an alternative to manually specifying sizes
|
|
29
|
-
* and steps
|
|
27
|
+
* As an alternative to manually specifying `sizes`, you can specify `min`,
|
|
28
|
+
* `max` and `steps`, and the `sizes` will be generated for you.
|
|
30
29
|
*/
|
|
31
30
|
min?: number;
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
32
|
+
* @see {@link PluginOptions.min}
|
|
34
33
|
*/
|
|
35
34
|
max?: number;
|
|
36
35
|
/**
|
|
37
|
-
* Configure the number of images generated between min and max
|
|
36
|
+
* Configure the number of images generated between `min` and `max`
|
|
37
|
+
* (inclusive)
|
|
38
38
|
*/
|
|
39
39
|
steps?: number;
|
|
40
40
|
/**
|
|
@@ -42,7 +42,8 @@ declare module '@docusaurus/plugin-ideal-image' {
|
|
|
42
42
|
*/
|
|
43
43
|
quality?: number;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* You can test ideal image behavior in dev mode by setting this to `false`.
|
|
46
|
+
* Tip: use network throttling in your browser to simulate slow networks.
|
|
46
47
|
*/
|
|
47
48
|
disableInDev?: boolean;
|
|
48
49
|
};
|
|
@@ -15,7 +15,7 @@ import {translate} from '@docusaurus/Translate';
|
|
|
15
15
|
import type {Props} from '@theme/IdealImage';
|
|
16
16
|
|
|
17
17
|
// Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/helpers.js#L59-L65
|
|
18
|
-
|
|
18
|
+
function bytesToSize(bytes: number) {
|
|
19
19
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
20
20
|
if (bytes === 0) {
|
|
21
21
|
return 'n/a';
|
|
@@ -25,10 +25,10 @@ const bytesToSize = (bytes: number) => {
|
|
|
25
25
|
return `${bytes} ${sizes[scale]}`;
|
|
26
26
|
}
|
|
27
27
|
return `${(bytes / 1024 ** scale).toFixed(1)} ${sizes[scale]}`;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
|
|
30
30
|
// Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/IdealImage/index.js#L43-L75
|
|
31
|
-
|
|
31
|
+
function getMessage(icon: IconKey, state: State) {
|
|
32
32
|
switch (icon) {
|
|
33
33
|
case 'noicon':
|
|
34
34
|
case 'loaded':
|
|
@@ -78,7 +78,7 @@ const getMessage = (icon: IconKey, state: State) => {
|
|
|
78
78
|
default:
|
|
79
79
|
throw new Error(`Wrong icon: ${icon}`);
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
|
82
82
|
|
|
83
83
|
export default function IdealImage(props: Props): JSX.Element {
|
|
84
84
|
const {alt, className, img} = props;
|