Skip to content

Commit c0062f8

Browse files
committed
Improve jsdoc on options
1 parent 2212902 commit c0062f8

2 files changed

Lines changed: 58 additions & 2 deletions

File tree

src/index.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,40 @@ export type {
1616
LqipFormat,
1717
} from './loader.js'
1818

19+
/**
20+
* The plugin options, they will be merged with {@linkcode DEFAULT_OPTIONS}
21+
*
22+
* @example
23+
*
24+
* ```typescript
25+
* const config: Config = {
26+
* plugins: [
27+
* [
28+
* 'native-ideal-image',
29+
* {
30+
* presets: {
31+
* card: {
32+
* sizes: [600, 800, 1000],
33+
* formats: ['avif', 'webp', 'jpeg'],
34+
* },
35+
* },
36+
* disableInDev: true,
37+
* } satisfies NativeIdealImageOptions,
38+
* ],
39+
* ],
40+
* }
41+
* ```
42+
*/
1943
export type NativeIdealImageOptions = Partial<{
2044
/**
2145
* File name template for output files
2246
*/
2347
fileNameTemplate: string
2448
/**
25-
* Image loader presets
49+
* Image loader presets, you can use them through URL queries like this:
50+
* `import image from 'ideal-img!./some-image.png?preset=card'`
51+
*
52+
* `default` preset is used when there's no preset query
2653
*/
2754
presets: Record<string, Preset>
2855
/**

src/mdx-plugin.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,42 @@ import type { Parent } from 'unist'
44
import { visit, EXIT } from 'unist-util-visit'
55
import { assetRequireAttributeValue, transformNode } from './utils.js'
66

7+
/**
8+
* The remark plugin options
9+
*
10+
* @example
11+
*
12+
* ```typescript
13+
* const config = {
14+
* presets: [
15+
* [
16+
* 'classic',
17+
* {
18+
* // The same for docs and blog
19+
* pages: {
20+
* remarkPlugins: [
21+
* [
22+
* nativeIdealImageRemarkPlugin,
23+
* {
24+
* swapOnLoad: true,
25+
* } satisfies NativeIdealImageRemarkPluginOptions,
26+
* ],
27+
* ],
28+
* },
29+
* },
30+
* ],
31+
* ],
32+
* }
33+
* ```
34+
*/
735
export type RemarkPluginOptions = Partial<{
836
/**
937
* The image loader preset to use
1038
*/
1139
preset: string
1240
/**
13-
* Swap (fade in) the actual image after it's fully loaded
41+
* Swap (fade in) the actual image after it's fully loaded,
42+
* this corresponds to `NativeIdealImageProps.swapOnLoad`
1443
*/
1544
swapOnLoad: boolean
1645
}>

0 commit comments

Comments
 (0)