mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
chore(pwa, sitemap, client-redirects, ideal-image): JSDoc for types (#6928)
* chore(pwa, sitemap, client-redirects, ideal-image): JSDoc for types * fix
This commit is contained in:
parent
284649c7c8
commit
bfe7ca6237
11 changed files with 129 additions and 52 deletions
|
@ -14,8 +14,7 @@ declare module '@docusaurus/plugin-ideal-image' {
|
|||
/**
|
||||
* Specify all widths you want to use; if a specified size exceeds the
|
||||
* original image's width, the latter will be used (i.e. images won't be
|
||||
* scaled up). You may also declare a default sizes array in the loader
|
||||
* options in your webpack.config.js.
|
||||
* scaled up).
|
||||
*/
|
||||
sizes?: number[];
|
||||
/**
|
||||
|
@ -25,16 +24,17 @@ declare module '@docusaurus/plugin-ideal-image' {
|
|||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* As an alternative to manually specifying sizes, you can specify min, max
|
||||
* and steps, and the sizes will be generated for you.
|
||||
* As an alternative to manually specifying `sizes`, you can specify `min`,
|
||||
* `max` and `steps`, and the `sizes` will be generated for you.
|
||||
*/
|
||||
min?: number;
|
||||
/**
|
||||
* See min above
|
||||
* @see {@link PluginOptions.min}
|
||||
*/
|
||||
max?: number;
|
||||
/**
|
||||
* Configure the number of images generated between min and max (inclusive)
|
||||
* Configure the number of images generated between `min` and `max`
|
||||
* (inclusive)
|
||||
*/
|
||||
steps?: number;
|
||||
/**
|
||||
|
@ -42,7 +42,8 @@ declare module '@docusaurus/plugin-ideal-image' {
|
|||
*/
|
||||
quality?: number;
|
||||
/**
|
||||
* Just use regular images in dev mode
|
||||
* You can test ideal image behavior in dev mode by setting this to `false`.
|
||||
* Tip: use network throttling in your browser to simulate slow networks.
|
||||
*/
|
||||
disableInDev?: boolean;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ import {translate} from '@docusaurus/Translate';
|
|||
import type {Props} from '@theme/IdealImage';
|
||||
|
||||
// Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/helpers.js#L59-L65
|
||||
const bytesToSize = (bytes: number) => {
|
||||
function bytesToSize(bytes: number) {
|
||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
if (bytes === 0) {
|
||||
return 'n/a';
|
||||
|
@ -25,10 +25,10 @@ const bytesToSize = (bytes: number) => {
|
|||
return `${bytes} ${sizes[scale]}`;
|
||||
}
|
||||
return `${(bytes / 1024 ** scale).toFixed(1)} ${sizes[scale]}`;
|
||||
};
|
||||
}
|
||||
|
||||
// Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/IdealImage/index.js#L43-L75
|
||||
const getMessage = (icon: IconKey, state: State) => {
|
||||
function getMessage(icon: IconKey, state: State) {
|
||||
switch (icon) {
|
||||
case 'noicon':
|
||||
case 'loaded':
|
||||
|
@ -78,7 +78,7 @@ const getMessage = (icon: IconKey, state: State) => {
|
|||
default:
|
||||
throw new Error(`Wrong icon: ${icon}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default function IdealImage(props: Props): JSX.Element {
|
||||
const {alt, className, img} = props;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue