Skip to content

Commit

Permalink
refactor(fff/strict): ♻️ update strict media
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Dec 20, 2023
1 parent f800a59 commit 5c5ae42
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/fff-flavored-frontmatter/src/utils/presets/strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ export interface StrictPresetOptions {
* - `undefined` - do not transform draft and draft flags
*/
draft?: boolean
/** transform media (alt / image / images / audio / video). */
media?: {
/**
* @defaultValue `undefined`
* - `true` - merge image into images[0] (image unchanged)
* - `false` - merge images[0] into image (images unchanged)
* - `undefined` - do not transform image and images
*/
array?: boolean
/**
* @defaultValue `undefined`
* - `object` - transform string media to object
* - `string` - transform object media to string
* - `undefined` - do not transform string/object media
*/
type?: 'object' | 'string'
}
/**
Expand Down Expand Up @@ -60,7 +73,7 @@ export const strictMedia = ({ media: options }: StrictPresetOptions = {}): FFFTr
image: ({ alt, image, images }) =>
strictMediaTransform(
options,
options?.array ? image : image ?? images?.[0],
options?.array === false ? (image ?? images?.[0]) : image,
alt,
),
images: ({ alt, image, images }) =>
Expand Down

0 comments on commit 5c5ae42

Please sign in to comment.