Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion processor/transform/mdxish/mdxish-jsx-to-mdast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function extractText(nodes: RootContent[]): string {
}

interface ImageAttrs {
aiAltText?: boolean | string;
align?: string;
alt?: string;
border?: boolean | string;
Expand Down Expand Up @@ -99,7 +100,7 @@ const transformAnchor = (jsx: MdxJsxTextElement): Anchor => {

const transformImage = (jsx: MdxJsxFlowElement): ImageBlock => {
const attrs = getAttrs<ImageAttrs>(jsx);
const { align, alt = '', border, caption, className, height, lazy, src = '', title = '', width } = attrs;
const { align, alt = '', aiAltText, border, caption, className, height, lazy, src = '', title = '', width } = attrs;

const validAlign = toImageAlign(align);
const sizing = width !== undefined ? String(width) : undefined;
Expand All @@ -108,6 +109,7 @@ const transformImage = (jsx: MdxJsxFlowElement): ImageBlock => {
alt,
src,
title,
...(aiAltText !== undefined && { aiAltText: toBool(aiAltText) }),
...(validAlign && { align: validAlign }),
...(border !== undefined && { border: toBool(border) }),
...(caption && { caption }),
Expand All @@ -120,6 +122,7 @@ const transformImage = (jsx: MdxJsxFlowElement): ImageBlock => {

return {
type: NodeTypes.imageBlock,
aiAltText: toBool(aiAltText),
align: validAlign,
alt,
border: toBool(border),
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface Plain extends Literal {
export type ImageAlign = 'center' | 'left' | 'right';

export interface ImageBlockAttrs {
aiAltText?: boolean;
align?: ImageAlign;
alt: string;
border?: boolean;
Expand Down
Loading